Asked by Varun Bhatia.
Write a recursive function treeToList(Node root) that takes an ordered binary tree and rearranges the internal pointers to make a circular doubly linked list out of the tree nodes. The”previous” pointers should be stored in the “small” field and the “next” pointers should be stored in the “large” field. The list should be arranged so that the nodes are in increasing order. Return the head pointer to the new list.
This is very well explained and implemented at: Convert a Binary Tree to a Circular Doubly Link List
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Inorder Tree Traversal without Recursion
- Practice questions for Linked List and Recursion
- Inorder Non-threaded Binary Tree Traversal without Recursion or Stack
- Print root to leaf paths without using recursion
- Remove duplicates from a sorted linked list using recursion
- Reverse a Doubly linked list using recursion
- DFS traversal of a tree using recursion
- Postorder traversal of Binary Tree without recursion and without stack
- Print alternate nodes of a linked list using recursion
- Leaf nodes from Preorder of a Binary Search Tree (Using Recursion)
- Delete nodes which have a greater value on right side using recursion
- Zig-Zag traversal of a Binary Tree using Recursion
- Find the node with minimum value in a Binary Search Tree using recursion
- Find the node with maximum value in a Binary Search Tree using recursion
- Find maximum and minimum element in binary tree without using recursion or stack or queue
- Traverse Linked List from middle to left-right order using recursion
- Find Maximum Level Sum in Binary Tree using Recursion
- Add the given digit to a number stored in a linked list using recursion
- Product of nodes at k-th level in a tree represented as string using Recursion
- Create a Circular List Structure For Given Value K Using Recursion