+ 2

# Is there any way to represent a binaary tree as singly linked list

I was asked this question in an interview how will you represent a binary tree as linked list(singly) , i still havent figured out.. plese help me

1 Answer

+ 3

You can always traverse a binary tree in ascending order of elements, because the left node is always smaller than the right. So I think that would be a way to start from the smallest element (first go left until you reach a leaf) and 'collect' all leafs into the singly linked list on ascending order. Reversing this process does not seem possible though (from list back to the same binary tree).