5. Provide a brief, but complete answer to cach question: How can we create a Ha
ID: 3903147 • Letter: 5
Question
5. Provide a brief, but complete answer to cach question: How can we create a Hash table that completely avoids collisions? Is this a good idea? What is the smallest number of modes in a complete binary tree with depth 5? c Should-dummy" nodes be included when counting the elements in a list? Why or why not? d. Is it true that the bottom level in a complete ascending Heap contains only the larger half of the values. ie, the elements with values that are greater or equal to the median? Why or why not? e. Will the result of the addition of two sparse matrices also be sparse? Why or why not? t Why it is important for a Hash Table to have extra space for the elements What happens when there is not enough extra space? Is an array the only choice when implementing a Heap? Why or why not? Will the smallest-valued mode in an ascending Heap always have two children. Why or why not?Explanation / Answer
1. Creating hash table to avoid collision:
Collision occurs in Hashing when key was colliding with existing value that was stored in hash table. To overcome the collision occurence, hash table has a concept called open addressing. The concept of Open addressing is locating the free space in the hash table and moving the value there to avoid collision.
Is it good? -- Absolutely yes, it was a nice choice to overcome the collision, it has three varying type of approach to overcome this collision.
1. Linear probing
2. Quadratic probing
3. Double Hashing.
2. Number of nodes in complete binary tree with depth 5 :
Complete binary tree of depth N has 2n+1-1 nodes
Depth = 5, so No of nodes = 25+1-1
= 64-1
= 63 nodes
3. Should Dummy node bee included in list?
Yes it should included in the list, Dummy nodes are used as head node in the list, it was the first real node.
4. Addition of 2 sparse matrix:
Addition of two sparse matrix will result in 3 sparse matrix, we will get the result by adding the two matrices and then by multiplying two matrices and then by gettting the transpose of the first matrices.
5. What is the need for extra space in hash table?
To avoid collision in hash table it is necessary to have extra space, so that we can map the hash value that will lead to collision to the extra space.
6. How to implement heap?
Yes heap sort will make use of array only, since we made the sorting possible with the help of index, the array based representation was space efficient. Hence heap sorting needs array only.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.