7. If we implement heap as min-heap , deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start.
Question: If we implement heap as min-heap , deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start.
Given Answer: A
Suggestion for Correct Answer:
8. If we implement heap as maximum heap , adding a new node of value 15 to the left most node of right subtree . What value will be at leaf nodes of the right subtree of the heap.
Question: If we implement heap as maximum heap , adding a new node of value 15 to the left most node of right subtree . What value will be at leaf nodes of the right subtree of the heap.
Given Answer: A
Suggestion for Correct Answer:
9. Why is heap implemented using array representations than tree(linked list) representations though both tree representations and heaps have same complexities?
for binary heap
-insert: O(log n)
-delete min: O(log n)
for a tree
-insert: O(log n)
-delete: O(log n)
Then why go with array representation when both are having same values ?
Question: Why is heap implemented using array representations than tree(linked list) representations though both tree representations and heaps have same complexities?for binary heap-insert: O(log n)-delete min: O(log n)for a tree-insert: O(log n)-delete: O(log n)Then why go with array representation when both are having same values ?
Given Answer: D
Suggestion for Correct Answer:
10. In a max-heap, element with the greatest key is always in the which node?