• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
July 03, 2023 |1.1K Views
Connect Nodes at Same Level
  Share   Like
Description
Discussion

In this video, we are given a binary tree. Our task is to connect all the adjacent nodes at the same level starting from the left-most node of that level, and ending at the right-most node using nextRight pointer by setting these pointers to point the next right for each node. 

For Example: 

For Input:  1
                 / \
                2   3
               / \    \
             4   5   6

The output will be: 1—>NULL
                               /  \
                             2–>3–>NULL
                            /   \      \
                          4–>5–>6–>NULL


Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-

Article: https://www.geeksforgeeks.org/connect-nodes-at-same-level/
Problem: https://practice.geeksforgeeks.org/problems/connect-nodes-at-same-level/1
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More