Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

HEAP TREE

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following is a max-heap?

a)
b)
c)
d)
2.

Consider a binary max-heap implemented using an array. Which one of the following array represents a binary max-heap?

a)

25,12,16,13,10,8,14

b)

25,12,16,10,13,8,14

c)

25,14,16,13,10,8,12

d)

25,14,12,13,10,8,16

3.

In a binary max heap containing n numbers, the smallest element can be found in time ?

a)

O(n)

b)

O( Log(n) )

c)

O( Log(Log(n)) )

d)

O(1)

4.

The elements 32, 15, 20, 30, 12, 25, 16 are inserted one by one in the given order into a Max Heap. The resultant Max Heap is.

a)
b)
c)
d)
5.

Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap is

a)

40, 30, 20, 10, 15, 16, 17, 8, 4, 35

b)

40, 35, 20, 10, 30, 16, 17, 8, 4, 15

c)

40, 30, 20, 10, 35, 16, 17, 8, 4, 15

d)

40, 35, 20, 10, 15, 16, 17, 8, 4, 30

6.

The minimum number of interchanges needed to convert the array 89, 19, 40, 17, 12, 10, 2, 5, 7, 11, 6, 9, 70 into a heap with the maximum element at the root is

a)

0

b)

1

c)

2

d)

3

7.

The number of nodes of height h in any complete n - element binary heap is

a)

hh

b)

2h2^h

c)

⌈n2h⌉\lceil\frac{n}{2^h}\rceil ( Ceiling function )

d)

⌈n2h+1⌉\lceil\frac{n}{2^{h+1}}\rceil ( Ceiling Function )

8.

Given a binary-max heap. The elements are stored in an arrays as 25, 14, 16, 13, 10, 8, 12. What is the content of the array after two delete operations?

a)

14,13,8,12,10

b)

14,12,13,10,8

c)

14,13,12,8,10

d)

14,13,12,10,8

9.

What is the best case Time Complexity of Heap Sort?

a)

O(n ⋅ log⁡n)O\left(n\ \cdot\ \log n\right)

b)

O(n2)O\left(n^2\right)

c)

O(n)O\left(n\right)

d)

O(log⁡(log⁡n))O\left(\log\left(\log n\right)\right)

10.

On which algorithm is heap sort based on?

a)

Fibonacci heap

b)

Binary tree

c)

Priority queue

d)

FIFO

11.

Identify the wrong statement

a)

All BST are binary trees

b)

Max-Heap is a complete binary tree

c)

All binary trees are BST

d)

AVL tree is a height balanced BST

12.

What is the time complexity of inserting an element into a binary max-heap?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

13.

In a binary max-heap, if the root node is removed, what is the next step to maintain the heap property?

a)

Replace it with the last element and heapify down

b)

Replace it with the first element and heapify up

c)

Replace it with the smallest child

d)

Do nothing, the heap is already valid

14.

What is the time complexity of deleting the maximum element from a binary max-heap?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

15.

In a binary max-heap, if the last element is removed, what happens to the structure of the heap?

a)

The heap remains unchanged

b)

The heap must be re-heapified

c)

The last element becomes the new root

d)

All elements are shifted to the left

16.

Which of the following is a property of a binary max-heap?

a)

Every parent node is less than or equal to its children

b)

The height of the tree is minimized

c)

The maximum element is always at the root

d)

All leaves are at the same level

17.

In a binary max-heap, what is the maximum number of nodes at level l?

a)

2l

b)

2{l+1}-1

c)

2l-1

d)

2{l+1}

18.

Which of the following operations is not typically supported by a binary max-heap?

a)

Insert

b)

Delete Max

c)

Find Min

d)

Heapify

19.

What is the space complexity of a binary max-heap?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n log n)

20.

In a binary max-heap, how is the parent node's index calculated from its child node's index?

a)

index/2

b)

index*2

c)

(⌊index − 1⌋)/2(\lfloor index\ -\ 1\rfloor)/2

d)

(⌊index+1⌋)/2(\lfloor index+1\rfloor)/2