In a tree, which description correctly defines a leaf?
6 Trees and Binary Search Trees Online Quiz Questions
Use this free practice quiz with 20 questions to review 6 Trees and Binary Search Trees, test your knowledge, and prepare for your next test or exam.
True or false: Every node in a binary tree has at most two children.
- A
True
- B
False
What traversal visits the keys of a binary search tree in sorted order?
Complete the recursive node-counting rule: if node is null, count(node) returns .
For the tree with root A, children B and C, B's children D and E, and C's right child F, which sequence is the preorder traversal?
- A
D, B, E, A, C, F
- B
A, B, D, E, C, F
- C
D, E, B, F, C, A
- D
A, B, C, D, E, F
Select all statements that correctly describe searching a binary search tree.
- A
A balanced BST can support search in O(logn) time.
- B
A skewed BST can require O(n) search time.
- C
A BST search follows one root-to-leaf path rather than necessarily visiting every node.
- D
Every ordinary BST guarantees O(logn) search time.
In the example tree whose root is A and whose path to D is A → B → D, what is the depth of D?
True or false: Level-order traversal is equivalent to breadth-first search from the root and typically uses a queue.
- A
True
- B
False
When deleting a BST node with exactly one child, replace the node with .
What is the auxiliary space complexity of level-order traversal when w is the maximum number of nodes at any one level?
- A
O(1)
- B
O(h)
- C
O(w)
- D
O(n2)
Select all statements that correctly describe important types of binary trees.
- A
In a full binary tree, each node has either zero or two children.
- B
In a complete binary tree, the last level is filled from left to right.
- C
In a perfect binary tree, all leaves are at the same depth.
- D
A degenerate tree requires every node to have two children.
Why can inserting the keys 1, 2, 3, 4, and 5 into an ordinary binary search tree cause operations to take linear rather than logarithmic time?
A perfect binary tree has height 3, where the root has height 0. How many nodes does it contain?
Consider a tree with root A. A has children B and C; B has children D and E; and C has child F. What is the depth of node F?
- A
1
- B
2
- C
3
- D
4
True or false: A level-order traversal processes every node at one depth before processing nodes at the next depth.
- A
True
- B
False
A binary tree has root 1, children 2 and 3, children 4 and 5 under node 2, and only a left child 6 under node 3. How should this tree be classified?
- A
Full but not complete
- B
Complete but not full
- C
Both full and complete
- D
Neither full nor complete
A binary tree has root M, left child J, right child R, right child K under J, and left child P under R. What is its preorder traversal?
- A
M, J, R, K, P
- B
J, K, M, P, R
- C
M, J, K, R, P
- D
M, R, P, J, K
A binary search tree has root 8, left child 3, right child 10, right child 6 under node 3, and right child 7 under node 6. Which sequence of nodes does a search for 7 visit?
- A
8, 10, 14, 13
- B
8, 3, 6, 7
- C
8, 3, 1, 7
- D
3, 6, 7
Using height 0 for a one-node tree, how many nodes are in a perfect binary tree of height 3?
Use height −1 for an empty tree. A tree has root X, children Y and Z, one child W under Y, and two children P and Q under Z. What is the height of the tree?
- A
0
- B
1
- C
2
- D
3
Related study packs and tools
02 — Information and Representation
A progressive guide to how computers encode numbers, text, images, and sound as binary data, including the trade-offs and limits of digital representation.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
04 Conditionals and Boolean Logic
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
10 — Data, Systems, and Applications
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
12 — Foundations Capstone
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.