Search code examples
traversalb-tree

B+ tree print elements is order


I am trying to implement a B+ tree myself, but I want to create a method that prints what elements does the B+ tree have. If I use a traversal(in or post order) I will get also the elements in the parent nodes, therefore I will have duplicate values. Is there a way to solve this thing? Thanks


Solution

  • Mark the nodes as you traverse them. Once the node is marked, it can't be traversed.