#### 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).

#### Logic :

- Modify the pre-order traversal algorithm by passing an extra argument of the current height (level) + 1

This post is a follow-up of

– JavaScript Linked List Example

– Create a binary search tree in javascript

– Binary tree traversal.

I recommend reading those posts first, as the following code uses the method from it.

#### Solution :

- CTCI_6_4.3