• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
November 18, 2023 |710 Views
PROBLEM OF THE DAY : 17/11/2023 | Binary Tree to CDLL
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of String but also build up problem-solving skills.

In this problem, we are given, a Binary Tree of N edges. The task is to convert this to a Circular Doubly Linked List (CDLL) in-place. The left and right pointers in nodes are to be used as previous and next pointers respectively in 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.

Example :

Input:
     1
   /   \
  3     2
Output:
3 1 2 
2 1 3

Explanation: After converting tree to CDLL when CDLL is is traversed from head to tail and then tail to head, elements are displayed as in the output.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/binary-tree-to-cdll/1
Solution Link:  https://ide.geeksforgeeks.org/online-cpp-compiler/69e8e37d-142e-4e0d-b1bc-e3d9a9b78cc0