Red-Black trees introduce the concept of 'color' to nodes (red or black). What is the primary purpose of this color scheme?
To maintain a relaxed form of balance, allowing for faster insertion and deletion compared to strictly balanced trees
To enable efficient searching for nodes based on their color
To simplify the visualization of the tree structure
To enforce a specific order of nodes during insertion
Why are two stacks often used in the iterative implementation of Postorder Traversal?
One stack stores the nodes to be visited, and the other stores the visited nodes.
One stack stores the nodes in preorder, and the other stores them in inorder, allowing us to derive the postorder.
One stack is used for the left subtree traversal, and the other for the right subtree traversal.
Two stacks are not strictly required; one stack is sufficient for iterative Postorder Traversal.
What is the worst-case time complexity of inserting a node into a Binary Search Tree (BST)?
O(1)
O(log n)
O(n)
O(n log n)
What is the primary advantage of using a balanced BST over an unbalanced BST?
Improved worst-case time complexity for search, insertion, and deletion
Reduced memory usage
Faster insertion operations
Guaranteed constant-time search complexity
Which of the following statements is true about AVL trees?
AVL trees guarantee a maximum height difference of 1 between the left and right subtrees of any node.
AVL trees are a type of Red-Black tree.
AVL trees are always perfectly balanced.
AVL trees do not require any rotations to maintain balance.
A full binary tree with 'k' internal nodes has how many total nodes?
2k
2k + 1
k
k + 1
What is the time complexity of efficiently finding the diameter of a binary tree?
O(n^2)
A complete binary tree with 'n' nodes has a height of?
n - 1
log2(n) + 1
n/2
floor(log2(n))
What is the maximum number of nodes at level 'l' in a binary tree?
l
l^2
2^l
2l
What is the primary advantage of using an iterative approach (with a stack) over recursion for Inorder Traversal?
Iterative traversal avoids function call overhead and potential stack overflow for very deep trees.
There is no significant advantage; both approaches have similar performance.
Iterative traversal is generally faster.
Iterative traversal is easier to understand and implement.