Given the binary tree create linked lists of the nodes at the same level
Problem description :
Convert a given binary tree to a linked list of all the nodes at each depth (if you have a binary tree with depth D, you'll have D linked lists).
- Modify the pre-order traversal algorithm by passing an extra argument of the current height (level) + 1
This post is a follow-up of
- Binary tree traversal.
I recommend reading those posts first, as the following code uses the method from it.