wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DAY 29 Binary Search Trees & AVL Tree- 18th July 2024

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following properties does a Binary Search Tree (BST) satisfy?

a)

Each node has at most two children.

b)

The left subtree of a node contains only nodes with keys less than the node's key.

c)

The right subtree of a node contains only nodes with keys greater than the node's key.

d)

All of the above

2.

What is the time complexity of searching for an element in a balanced Binary Search Tree?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

3.

What is the in order traversal of the BST shown below? 4 2 1 3 6 5 7

a)

4 2 1 3 6 5 7

b)

1 2 3 4 5 6 7

c)

7 6 5 4 3 2 1

d)

4 2 3 1 6 5 7

4.

Which operation does not necessarily preserve the BST property?

a)

Insertion

b)

Deletion

c)

Searching

d)

None of the above

5.

What is the height of a BST with 7 nodes in its most balanced form?

a)

2

b)

3

c)

4

d)

5

6.

Which of the following algorithms is used for searching in a BST?

a)

Breadth-First Search

b)

Depth-First Search

c)

Binary Search

d)

Linear Search

7.

Which of the following cases can occur when deleting a node from a BST?

a)

The node is a leaf.

b)

The node has one child.

c)

The node has two children.

d)

All of the above

8.

In a BST, the node with the minimum value is found:

a)

At the root

b)

In the leftmost node

c)

In the rightmost node

d)

In the middle node

9.

What is the successor of a node in a BST?

a)

The node with the next higher key

b)

The node with the next lower key

c)

The left child

d)

The right child

10.

What is the worst-case time complexity of inserting a new node in an unbalanced BST?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

11.

What is an AVL tree?

a)

A tree with all levels filled

b)

A binary tree with an additional balance factor

c)

A tree with a maximum of 3 children per node

d)

A binary tree with height equal to the number of nodes

12.

What is the balance factor of a node in an AVL tree?

a)

Height of left subtree - Height of right subtree

b)

Height of right subtree - Height of left subtree

c)

The number of children

d)

The difference in the number of nodes between the left and right subtrees

13.

An AVL tree is balanced if, for every node in the tree, the balance factor is:

a)

-1, 0, or 1

b)

-2, 0, or 2

c)

-3, 0, or 3

d)

0 only

14.

Which of the following operations may cause an AVL tree to become unbalanced?

a)

Insertion

b)

Deletion

c)

Searching

d)

Both 1 and 2

15.

What is the time complexity of rebalancing an AVL tree?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

16.

Which rotation is used to balance an AVL tree when a node is inserted into the right subtree of the right child?

a)

Left Rotation

b)

Right Rotation

c)

Left-Right Rotation

d)

Right-Left Rotation

17.

In an AVL tree, what type of rotation is performed when a node is inserted into the left subtree of the right child?

a)

Left Rotation

b)

Right Rotation

c)

Left-Right Rotation

d)

Right-Left Rotation

18.

After performing an insertion in an AVL tree, the balance factor of a node becomes -2. This implies:

a)

The left subtree is higher by 2 levels.

b)

The right subtree is higher by 2 levels.

c)

The tree is perfectly balanced.

d)

None of the above

19.

What type of tree traversal is often used to print the elements of an AVL tree in sorted order?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Level Order

20.

In an AVL tree, which of the following properties is true for every node?

a)

Each node has exactly two children.

b)

The tree is perfectly balanced.

c)

The height difference between the left and right subtrees of any node is at most 1.

d)

The tree cannot be empty.