Engineering Questions with Answers - Multiple Choice Questions

# Data Structure MCQ – Weak Heap

1 - Question

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) Every left and right child of node has same value as parent node

Explanation: This is the property of a weak heap.

2 - Question

Left child of parent node has value lesser than the parent node.
a) True
b) False

Explanation: Weak heap has no left child.

3 - Question

What is the other name of weak heap?
a) Min-heap
b) Max-heap
c) Relaxed -heap
d) Leonardo heap

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

4 - Question

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)

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

5 - Question

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) n2

Explanation: The total comparisons in finding smallest and largest elements is n + ((n+1)/2) – 2.

6 - Question

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) O (n*logn)

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 - Question

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

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 - Question

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) h-2