NEW
Font size
WorksheetsDSA (Quiz 4) - Trees
Total questions: 20
Worksheet time: 10mins
What is the root node of a tree?
A node with no parent
A node with two children
A node with no children
A node at the lowest level
Which of the following is true about trees?
Trees can have cycles
Trees can have multiple roots
Trees are a type of graph
Trees cannot be represented using linked lists
What is the degree of a node?
Number of ancestors
Number of children
Number of siblings
Number of edges
Which term refers to nodes with the same parent?
Root
Siblings
Leaf
Height
What is the height of a tree?
The number of edges from the root to a node
The total number of nodes in the tree
The longest path from the root to a leaf
The number of leaf nodes
Which of the following is true for a binary tree?
Each node can have at most two children
Each node can have an unlimited number of children
A binary tree can have cycles
The root node always has exactly two children
Which traversal visits the left subtree, then the root, then the right subtree?
Preorder
Inorder
Postorder
Level-order
Which tree traversal is useful for evaluating mathematical expressions?
Preorder
Inorder
Postorder
Level-order
Which data structure is used for level-order traversal of a binary tree?
Stack
Queue
Linked List
Heap
What is the time complexity of searching in a balanced binary search tree (BST)?
O(1)
O(n)
O(log n)
O(n²)
In a BST, where is a smaller value placed relative to a node?
Left subtree
Right subtree
Root node
It depends on the tree type
What happens when you delete a node with two children in a BST?
The left child replaces the deleted node
The right child replaces the deleted node
The in-order successor or predecessor replaces the deleted node
The node is replaced by NULL
What is the best case time complexity for searching in a BST?
O(1)
O(n)
O(log n)
O(n²)
What is the worst-case time complexity for searching in an unbalanced BST?
O(1)
O(n)
O(log n)
O(n²)
Which operation maintains the balance of an AVL tree?
Rotation
Insertion
Traversal
Level-order search
What is the balance factor of an AVL tree node?
Difference between left and right subtree heights
Number of children
Total number of nodes
Sum of node values
What is the main advantage of Red-Black Trees?
They are easier to implement than AVL trees
They always have a balance factor of 0
They allow faster insertions and deletions than AVL trees
They do not require balancing
Which property ensures that a Red-Black Tree remains balanced?
Every path from a node to descendant NIL nodes has the same number of black nodes
Every node is either red or black
Root must be black
Red nodes cannot have red children
What is the primary use of Red-Black Trees in real-world applications?
Operating system scheduling
Sorting numbers
Managing social media data
Cryptographic algorithms
Which of the following is NOT a balanced tree?
AVL Tree
Red-Black Tree
Binary Search Tree (BST)
B-Trees
