Question 1
In a max-heap, element with the greatest key is always in the which node?
Leaf node
First node of left sub tree
root node
First node of right sub tree
Good Job!
Oops!
Explanation: This is one of the property of max-heap that root node must have key greater than its children.
Please login to submit your explanation
You can check your performance of this question after Login/Signup
Start
Question 2
Heap exhibits the property of a binary tree?
True
False
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.
O(log n)
O(h)
O(log n) & O(h)
None of the mentioned
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
O(logn)
O(n)
O(nlogn)
O(n2)
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 ________________
Priority queue
Stack
A decreasing order array
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.
Question 6
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.
2
100
17
3
Explanation: As the root is deleted and node with value 100 is used as replaced one. There is a violation of property that root node must have value less than its children. So there will be shuffling of node with value 100 with node of value 2. And thus 2 becomes root. And it will remain to be at root after all the possible operations . So the value at root will be 2.
Question 7
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.
15 and 1
25 and 1
3 and 1
2 and 3
Explanation: As 15 is less than 25 so there would be no violation and the node will remain at that position.So leaf nodes with value 15 and 1 will be at the position in right sub tree.
Question 8
An array consist of n elements. We want to create a heap using the elements. The time complexity of building a heap will be in order of
O(n*n*logn)
O(n*logn)
O(n*n)
O(n *logn *logn)
Explanation: The total time taken will be N times the complexity of adding a single element to the heap. And adding a single element takes logN time, so That is equal to N*logN.
Question 9
On which algorithm is heap sort based on?
Fibonacci heap
Binary tree
FIFO
Explanation: Heap sort is based on the algorithm of priority queue and it gives the best sorting time.
Question 10
In what position does the array for heap sort contains data?
0
1
-1
anywhere in the array
Explanation: The array for heap sort contains data at position 0 whereas for a binary heap, array begins at 1. This is the reason for its complexity.
Please login to report
Completed
0/0
Accuracy
0%
Login/Signup to comment
Login/Signup to comment