What will be the order of new heap created after union of heap H1 and H2 when created by the following code.Initially both are of the order n.
FIB_UNION(H1,H2)
{
H =MAKE_HEAP()
min[H]= min[H1]
concatenate the root list of H2 with the root list of H
if (min[H1] = NIL) or (min[H2]!= NIL and min[H2] < min[H1])
then min[H] = min[H2]
n[H]= n[H1] + n[H2]
free the objects H1 and H2
return H
}
FIB_UNION(H1,H2)
{
H =MAKE_HEAP()
min[H]= min[H1]
concatenate the root list of H2 with the root list of H
if (min[H1] = NIL) or (min[H2]!= NIL and min[H2] < min[H1])
then min[H] = min[H2]
n[H]= n[H1] + n[H2]
free the objects H1 and H2
return H
}A. n+1
B. n+n/2
C. nlogn
D. 2*n
Answer: Option A
What is the time complexity of inserting an element into a binary heap?
A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
Which of the following is true for a min-heap?
A. The root node is the smallest element, and every parent node is smaller than its children.
B. The root node is the largest element, and every parent node is larger than its children.
C. All nodes are arranged in a complete binary tree.
D. The tree is always balanced.
In a max-heap, which node property is true?
A. Every parent node is greater than or equal to its children.
B. Every parent node is less than or equal to its children.
C. All nodes have the same value.
D. The root node is always the smallest element.
How do you maintain the heap property after deleting the root node?
A. By performing a heapify operation.
B. By reordering the entire heap.
C. By inserting a new element at the root.
D. By performing an inorder traversal.

Join The Discussion