Question: Perform a level order traversal of a binary tree. Convert the tree into doubly linked list (order of the elements should be level ordered). No extra space used and it is fine to destroy the tree.
Hint: Use a Queue, insert the children of each child into the queue. Remove the element from the queue and keep doing this until queue is empty.
Solution: Insert root’s lchild and rchild and make root’s lchild to nullptr and rchild to to the lchild. Keep doing this until queue is empty.
The implementation for this is in the page Binary tree in the method TreeToDoublyLinkedList