Flatten Nested Tree Iterator
Given a nested tree hierarchy (e.g., categories and subcategories), implement an iterator class with a next() method that traverses and returns each node's value in pre-order (top-down, left-to-right) sequence.
Asked at:
Adobe
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early June, 2026
Adobe
Senior
Books ├── Fiction │ ├── Harry Potter │ └── Lord of the Rings └── Science Fiction └── Dune Implement an iterator that traverses the hierarchy and implements next(). next() prints the name of root/category/subcategory. iterator.next() # Books iterator.next() # Fiction iterator.next() # Harry Potter iterator.next() # Lord of the Rings iterator.next() # Science Fiction iterator.next() # Dune
Hello Interview Premium
Your account is free and you can post anonymously if you choose.