• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
June 21, 2023 |1.5K Views
Print a Binary Tree in Vertical Order
Description
Discussion

In this video, we will discuss the problem "Print a Binary Tree in Vertical Order". If there are multiple nodes passing through a vertical line, then they should be printed as they appear in level order traversal of the tree. The below example will explain the task at hand more thoroughly. 

Example: 

Input:     1
              /   \
            2       3
          /   \   /   \
        4     5 6     7
                    \      \
                      8      9

Output: 
4 2 1 5 6 3 8 7 9 

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/print-binary-tree-vertical-order/
Problem: https://practice.geeksforgeeks.org/problems/print-a-binary-tree-in-vertical-order/1
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

 

Read More