Given a binary tree (with left and right child only), how do you write a recursive function to make it into a simple linked list in-place? (no new data structure should be created. Pseudo code is ok). Suppose each node has an integer value, like 123, or 2, or 3. The final link list should have all the nodes in the tree. The order is not important.
Update: needs to be in-place. no new data structure should be created.
There are always different ways to iterate over a tree, as there are:
You can choose either of them to form your list…
For example (pseudocode, PreOrder):
Remenber: If you perfomed an InOrder on a binary search tree you would get the elements in sorted order.