I was studying tree algorithms and almost all algorithms use recursion for traversing of course traversal can be done without recursion as well (by creating stack data structure and while loop). But out of curiosity wanted to know how these tree data structures are traversed when there are millions or billions of nodes exist in tree ? of course these questions are asked in interviews as well.
Some of the approaches I can just think of are
- Store tree in multiple files as different subtrees and traverse through files
- Distribute tree across different machines
- Store tree in database in table structure and design query for traversal
Any better approaches, if any one could share link to study material for such kind of problems will be help.