Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

unit-4 test-2

Total questions: 20

Worksheet time: 57mins

Name
Class
Date
1.

Suppose a binary search tree with 1000 distinct elements is also a complete binary tree. The tree is stored using the array representation of binary heap trees. Assuming that the array indices start with 0, the 3rd largest element of the tree is stored at index ___________.

a)

509

b)

409

c)

510

d)

408

2.

The preorder traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?


a)

20, 19, 18, 16, 15, 12, 11, 10

b)

10, 11, 12, 15, 16, 18, 19, 20

c)

11, 12, 10, 16, 19, 18, 20, 15

d)

19, 16, 18, 20, 11, 12, 10, 15

3.

The postorder traversal of a binary tree is 8,9,6,7,4,5,2,3,1. The inorder traversal of the same tree is 8,6,9,4,7,2,5,1,3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is ______.

a)

3

b)

4

c)

5

d)

2

4.

The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are

a)

63,6

b)

64,5

c)

32,6

d)

31,5

5.

Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)?

I. 3, 5, 7, 8, 15, 19, 25
II. 5, 8, 9, 12, 10, 15, 25
III. 2, 7, 10, 8, 14, 16, 20
IV. 4, 6, 7, 9 18, 20, 25

a)

I. IV.

b)

II. III.

c)

II. IV.

d)

II.

6.

What are the worst-case complexities of insertion and deletion of a key in a binary search tree?

a)

log(n), log(n)

b)

n,n

c)

n, log(n)

d)

log(n),n

7.

A binary tree T has 20 leaves. The number of nodes in T having two children is _______________.

a)

20

b)

19

c)

18

d)

22

8.

Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in T that have exactly two children are ________.

a)

200

b)

202

c)

199

d)

201

9.

While inserting the elements 71,65,84,69,67,83 in an empty binary search tree in the sequence shown, the element in the lowest level is

a)

65

b)

67

c)

83

d)

69

10.

Consider a rooted n node binary tree represented using pointers. The best upper bound on the time required to determine the number of subtrees having exactly 4 nodes O(na Logbn ).

Then the value of a + 10b is _________

a)

4

b)

3

c)

2

d)

1

11.

The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:

a)

2h-1

b)

2h-2

c)

2h+1-1

d)

2h+1

12.

The maximum number of binary trees that can be formed with three unlabeled nodes is:

a)

3

b)

1

c)

5

d)

4

13.

A scheme for storing binary trees in an array X is as follows. Indexing of X starts at 1 instead of 0. the root is stored at X[1]. For a node stored at X[i], the left child, if any, is stored in X[2i] and the right child, if any, in X[2i+1]. To be able to store any binary tree on n vertices the minimum size of X should be

a)

log2 n

b)

n

c)

2n+1

d)

2n-1

14.

In a binary tree, the number of internal nodes of degree 1 is 5, and the number of internal nodes of degree 2 is 10. The number of leaf nodes in the binary tree is

a)

10

b)

12

c)

15

d)

11

15.

The numbers 1, 2, ........, n are inserted in a binary search tree in some order. In the resulting tree, the right subtree of the root contains p nodes. The first number to be inserted in the tree must be

a)

p

b)

p+1

c)

n-p

d)

n-p+1

16.

Consider the following nested representation of binary trees: (X Y Z) indicates Y and Z are the left and right sub stress, respectively, of node X. Note that Y and Z may be NULL, or further nested. Which of the following represents a valid binary tree?

a)

(1 2 (4 5 6 7))

b)

(1 (2 3 4) 5 6 7)

c)

(1 (2 3 4) (5 6 7))

d)

(1 (2 3 null) (4 5 ))

17.

Which of the following statements is false?

a)

tree with n nodes has n-1 edges

b)

we can construct a labelled binary tree using postorder and inorder results

c)

a complete binary tree with n internal nodes has n+1 leaves

d)

the max number of nodes of a binary tree of height h is

2h+1-1

18.

In the balanced binary tree in Fig. given below, how many nodes will become unbalanced when a node is inserted as a child of the node “g”?

a)

1

b)

7

c)

8

d)

3

19.

A binary tree T has n leaf nodes. The number of nodes of degree 2 in T is:

a)

log2n

b)

n-1

c)

n

d)

2n

20.

If the no of leaves in a tree is not a power of 2,then the tree is not a binary tree.

a)

true

b)

false