# Data Structure Questions and Answers-Heap

## Click on any option to know the CORRECT ANSWERS

 Question 1
In a max-heap, element with the greatest key is always in the which node?
 A Leaf node B First node of left sub tree C root node D First node of right sub tree
English literature Questions answers

Question 1 Explanation:
This is one of the property of max-heap that root node must have key greater than its children.

 Question 2
Heap exhibits the property of a binary tree?
 A True B False
English literature Questions answers

Question 2 Explanation:
Yes, Because the leaf nodes are present at height h or h-1, which is a property of complete binary tree.

 Question 3
What is the complexity of adding an element to the heap.
 A O(log n) B O(h) C O(log n) & O(h) D None of the mentioned

Question 3 Explanation:
The total possible operation in re locating the new location to a new element will be equal to height of the heap.

 Question 4
The worst case complexity of deleting any arbitrary node value element from heap is
 A O(logn) B O(n) C O(nlogn) D O(n2)

Question 4 Explanation:
The total possible operation in deleting the existing node and re locating new position to all its connected nodes will be equal to height of the heap.

 Question 5
Heap can be used as .....
 A Priority queue B Stack C A decreasing order array D None of the mentioned
Aptitude test Questions answers

Question 5 Explanation:
The property of heap that the value of root must be either greater or less than both of its children makes it work like a priority queue.

There are 5 questions to complete.