Programming & Data Structures
⏱ ~3-min readAceMark GuideWhat this topic is really about
An in-order traversal of a binary search tree produces values in ascending order.. An in-order traversal visits the left subtree, then the node, then the right subtree, which for any binary search tree produces the values in ascending order: 20, 30, 40, 50, 60, 70.
A recursive function without a base case exhausts the call stack, causing a stack overflow error.. Each recursive call adds a new frame to the call stack, and without a base case the stack grows without limit until memory is exhausted, producing a stack overflow.
See the mechanism
The queue starts with the front and rear pointers at index 6 and contains 0 elements. A diagram for this topic isn't available yet — the worked example below walks the same reasoning step by step.
An exam-style question, fully explained
A queue is implemented as a circular array of size 8 with front pointer = 6 and rear pointer = 6, and the queue currently contains 0 elements. After enqueuing three values, what will the rear pointer be?
- Identify what the question tests: A queue is implemented as a circular array of size 8 with front pointer = 6 and rear pointer = 6, and the queue currently contains 0 elements..
- Starting at index 6 and adding three elements moves through positions 6, 7, then wraps to 0, leaving the rear at index 1 because (6 + 3) mod 8 = 1.
- A value of 9 is wrong because a circular array of size 8 has no index beyond 7 and must wrap with modulo.
- Why it matters: The queue starts with the front and rear pointers at index 6 and contains 0 elements. After enqueuing three values, the rear pointer moves to index 7 and then wraps around to index 0, and finally to index 1, because (6 + 3) mod 8 = 1. This wrapping behavior is a key characteristic of circular arrays.
Traps the examiner sets
- People often forget that the rear pointer wraps around to the start of the array when it reaches the end, or they misunderstand how the modulo operator works in this context.
- The insertion order or a left-node-right post-order arrangement are not correct.
- A queue is often considered, but it would undo the oldest action first due to its first-in-first-out behavior.
- Students often confuse stack overflow with other runtime errors such as division by zero or array out‑of‑bounds, but only unbounded recursion directly leads to stack overflow.
- A value of 9 is wrong because a circular array of size 8 has no index beyond 7 and must wrap with modulo.
Test your recall
Answer each from memory — you'll see instantly whether you're right and why.
Run a focused 10-question mini-mock on Programming & Data Structures and see it stick.
Practice more of this topic →