Question
add(int k)
{
heap_size++;
int i = heap_size - 1;
harr[i] = k;
while (i != 0 && harr[parent(i)] < harr[i])
{
swap(&harr[i], &harr[parent(i)]);
i = parent(i);
}
}
a.
Line -3
b.
Line – 5
c.
Line – 6
d.
Line -7
Posted under Data Structures and Algorithms
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. For construction of a binary heap with property that parent node has value less than child node.In reference to that which line is incorrect. Line indexed from 1.
Similar Questions
Discover Related MCQs
Q. Choose the correct properties of weak-heap.
View solution
Q. Left child of parent node has value lesser than the parent node.
View solution
Q. What is the other name of weak heap?
View solution
Q. What is the worst case time in searching minimum value in weak -heap?
View solution
Q. The total comparisons in finding both smallest and largest elements are
View solution
Q. Does there exist a heap with seven distinct elements so that the Inorder traversal gives the element in sorted order.
View solution
Q. The leaf node for a heap of height h will be at which position.
View solution
Q. The main distinguishable characterstic of a binomial heap from a binary heap is that
View solution
Q. The number of trees in a binomial heap with n nodes is
View solution
Q. In a binomial heap the root value is greater than left child and less than right child.
View solution
Q. What is order of resultant heap after merging two tree of order k?
View solution
Q. Time taken in decreasing the node value in a binomial heap is
View solution
Q. Which of these operations have same complexities?
View solution
Q. The Statement “Fibonacci heap has better amortized running time in compare to a binomial heap”.
View solution
Q. Given a heap of n nodes.The maximum number of tree for building the heap is.
View solution
Q. Choose the option with function having same complexity for a fibonacci heap.
View solution
Q. What is a hash table?
View solution
Q. If several elements are competing for the same bucket in the hash table, what is it called?
View solution
Q. What is direct addressing?
View solution
Q. What is the search complexity in direct addressing?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!