What information entered the process?
Labs / Computer Science
Binary Search Tree
Pick a value and insert it — every number finds its slot by going left when it is smaller and right when it is larger. Then run a search to watch the comparison path light up, or an in-order traversal to see the tree unspool into a sorted list. Click any node to search straight for it.
Labs / Computer Science / Binary Search Tree
Binary Search Tree
Pick a value and insert it — every number finds its slot by going left when it is smaller and right when it is larger. Then run a search to watch the comparison path light up, or an in-order traversal to see the tree unspool into a sorted list. Click any node to search straight for it.
Why it matters
Why explore this?
Computer science turns clear rules into reliable processes. This model lets you step through those rules and see how each decision changes the result.
Explore
Try the model
Investigate
Questions to test
Predict first, try it in the model, then use what you observe to answer.
What to try
- Reset, then insert values in increasing order (10, 20, 30…). Why does the tree turn into a lopsided line instead of a bushy shape?
- How many comparisons does a search take in a balanced tree versus that lopsided one — and how does the height readout predict it?
- Run the in-order traversal. Why does visiting left, then node, then right always come out perfectly sorted?
- Search for a value that is not in the tree. Where does the path stop, and what does that tell you about where it would be inserted?
- Add nodes with Random until the tree is large. What happens to the height as the node count doubles?
Explain
Make sense of what happened
Trace the process one step at a time. Name the rule used at each important step, then explain why the final result follows from those rules.
Check
Before you leave
Which rule changed it?
Why did the process produce this result?
If you can answer all three using evidence from the model, you understand the main idea. If not, return to Explore and change one setting at a time.