wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DSA (Quiz 4) - Trees

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the root node of a tree?

a)

A node with no parent

b)

A node with two children

c)

A node with no children

d)

A node at the lowest level

2.

Which of the following is true about trees?

a)

Trees can have cycles

b)

Trees can have multiple roots

c)

Trees are a type of graph

d)

Trees cannot be represented using linked lists

3.

What is the degree of a node?

a)

Number of ancestors

b)

Number of children

c)

Number of siblings

d)

Number of edges

4.

Which term refers to nodes with the same parent?

a)

Root

b)

Siblings

c)

Leaf

d)

Height

5.

What is the height of a tree?

a)

The number of edges from the root to a node

b)

The total number of nodes in the tree

c)

The longest path from the root to a leaf

d)

The number of leaf nodes

6.

Which of the following is true for a binary tree?

a)

Each node can have at most two children

b)

Each node can have an unlimited number of children

c)

A binary tree can have cycles

d)

The root node always has exactly two children

7.

Which traversal visits the left subtree, then the root, then the right subtree?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Level-order

8.

Which tree traversal is useful for evaluating mathematical expressions?

a)

Preorder

b)

Inorder

c)

Postorder

d)

Level-order

9.

Which data structure is used for level-order traversal of a binary tree?

a)

Stack

b)

Queue

c)

Linked List

d)

Heap

10.

What is the time complexity of searching in a balanced binary search tree (BST)?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n²)

11.

In a BST, where is a smaller value placed relative to a node?

a)

Left subtree

b)

Right subtree

c)

Root node

d)

It depends on the tree type

12.

What happens when you delete a node with two children in a BST?

a)

The left child replaces the deleted node

b)

The right child replaces the deleted node

c)

The in-order successor or predecessor replaces the deleted node

d)

The node is replaced by NULL

13.

What is the best case time complexity for searching in a BST?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n²)

14.

What is the worst-case time complexity for searching in an unbalanced BST?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n²)

15.

Which operation maintains the balance of an AVL tree?

a)

Rotation

b)

Insertion

c)

Traversal

d)

Level-order search

16.

What is the balance factor of an AVL tree node?

a)

Difference between left and right subtree heights

b)

Number of children

c)

Total number of nodes

d)

Sum of node values

17.

What is the main advantage of Red-Black Trees?

a)

They are easier to implement than AVL trees

b)

They always have a balance factor of 0

c)

They allow faster insertions and deletions than AVL trees

d)

They do not require balancing

18.

Which property ensures that a Red-Black Tree remains balanced?

a)

Every path from a node to descendant NIL nodes has the same number of black nodes

b)

Every node is either red or black

c)

Root must be black

d)

Red nodes cannot have red children

19.

What is the primary use of Red-Black Trees in real-world applications?

a)

Operating system scheduling

b)

Sorting numbers

c)

Managing social media data

d)

Cryptographic algorithms

20.

Which of the following is NOT a balanced tree?

a)

AVL Tree

b)

Red-Black Tree

c)

Binary Search Tree (BST)

d)

B-Trees