BST Iterator Design
📖 Scenario: You are building a tool to explore a collection of numbers stored in a special tree called a Binary Search Tree (BST). This tree keeps numbers in order, so you can find the smallest number quickly. You want to create a helper called a BST Iterator that lets you look at the numbers one by one, from smallest to largest, without changing the tree.
🎯 Goal: Build a BST Iterator that can move through the tree in order, showing one number at a time. You will create the tree, set up the iterator, write the logic to get the next number, and finally print the numbers in order.
📋 What You'll Learn
Create a BST with the exact nodes given
Create a stack to help with the iterator
Write a function to move to the next smallest number
Print the numbers in ascending order using the iterator
💡 Why This Matters
🌍 Real World
BST Iterators are useful in databases and search engines where you need to access sorted data efficiently without loading everything at once.
💼 Career
Understanding BST Iterators helps in roles involving data structures, algorithms, and system design, especially for optimizing search and retrieval operations.
Progress0 / 4 steps