This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Weak Heap”.

1. Choose the correct properties of weak-heap.

a) Every node has value greater than the value of child node

b) Every right child of node has greater value than parent node

c) Every left child of node has greater value than parent node

d) None of the mentioned

View Answer

Explanation: This is the property of a weak -heap.

2. Left child of parent node has value lesser than the parent node.

a) True

b) False

View Answer

Explanation: Weak heap has no left child.

3. What is the other name of weak heap?

a) Min-heap

b) Max-heap

c) Relaxed -heap

d) Leonardo heap

View Answer

Explanation: Relaxed heap is just another name of weak heap.

4. What is the worst case time in searching minimum value in weak -heap?

a) O(log n)

b) O(n)

c) O(n logn)

d) O(1)

View Answer

Explanation: Weak heap is an array based form that supports the operation of finding minimum in O(1).

5. The total comparisons in finding both smallest and largest elements are

a) 2*n +2

b) n + ((n+1)/2) -2

c) n+logn

d) n^{2}

View Answer

Explanation: None.

6. What is the complexity of given function of insertion.

insert(int n) { if(buffer_size()< maxi_biffer_size()) buffer_aar[ind]==n; else move_to_heap(buffer,buffer+maxi_buffer_size()) }

a) O(logn)

b) amortized O(1)

c) O(n)

d) None of the mentioned

View Answer

Explanation: Use a buffer array to store a fixed number of elements when the buffer is full the content of buffer is moved to heap.As a result the complexity

is amotized O(1).

7. Does there exist a heap with seven distinct elements so that the Inorder traversal gives the element in sorted order.

a) Yes

b) No

View Answer

Explanation: No, The inorder traversal will not give elements in sorted order. As heap is implemented as either min-heap or max-heap, the root will be have highest or lowest value than remaining values of the nodes. So this traversal will not give a sorted list.

8. The leaf node for a heap of height h will be at which position.

a) h

b) h-1

c) h or h-1

d) None of the mentioned

View Answer

Explanation: A complete binary tree is also a heap so by the property of binary tree the leaf nodes will be must at height h or h-1.

**Sanfoundry Global Education & Learning Series – Data Structure.**

To practice all areas of Data Structure, __here is complete set of 1000+ Multiple Choice Questions and Answers__.