To add a new element X to a heap:
A) if the tree is empty,make X the root of a new tree;otherwise,compare X to the root,if X is less,put it in the left subtree,if it is greater,put in the right subtree
B) First add X in the position of the root.If X is a leaf,or is less than its children,stop.Otherwise,repeatedly swap X with the smaller of its two children until X becomes a leaf,or becomes less than its children.
C) Add X as a leaf,taking care to preserve the completeness of the heap.If X is now the root,or is greater than its parent,stop.Otherwise,repeatedly swap X with its parent until X becomes the root,or becomes greater than its parent.
D) insert X using the same algorithm for insertion in a binary search tree.If the tree remains balanced,stop.Otherwise,execute a rebalancing operation.
Correct Answer:
Verified
Q31: A complete binary tree with N nodes
Q32: The level of a node X in
Q33: Consider the operation of deleting the root
Q34: Traversing a binary search tree in inorder
A)
Q35: To find the minimum node in a
Q37: A complete binary tree with N nodes
Q38: The order condition that characterizes a heap
Q39: To find the minimum element stored in
Q40: The depth of a binary tree
A) is
Q41: A ternary tree is like a binary
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents