• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 21, 2024 |1.4K Views

Print Bottom View of Binary Tree

  Share   Like
Description
Discussion

In this video, we are given a Binary Tree, The task is to print the bottom view from left to right. 
Example:

Input:              20
                   /     \
               8         22
            /     \     /     \
         5        3  4      25
                 /    \      
             10       14
Output: 5 10 4 14 25. 
Explanation: If there are multiple bottom-most nodes for a horizontal distance from the root, then print the later one in the level traversal. 3 and 4 are both the bottom-most nodes at a horizontal distance of 0, we need to print 4. 

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