Difficulty Level: Medium

Submissions: 1029 Accuracy:


Binary Tree to CDLL (Function Problem)

Given a Binary Tree (BT), convert it to a Circular Doubly Linked List(DLL) In-Place. The left and right pointers in nodes are to be used as previous and next pointers respectively in converted CDLL. The order of nodes in CDLL must be same as Inorder of the given Binary Tree. The first node of Inorder traversal (left most node in BT) must be head node of the CDLL.

The task is to complete the method which takes a arguments, root of Binary Tree.
The struct Node has a data part which stores the data, pointer to left child and pointer to right child.
There are multiple test cases. For each test case, this method will be called individually.

The function should return the head of CDLL.

1 <=T<= 100
1 <=Number of nodes<= 100
1 <=Data of a node<= 100


1 2 R 1 3 L
10 20 L 10 30 R 20 40 L 20 60 R
3 1 2 
2 1 3
40 20 60 10 30 
30 10 60 20 40

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use, generate link and share the link here.