• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
June 03, 2022 |480 Views
Smallest value in each level of Binary Tree
  Share   Like
Description
Discussion

The idea is to recursively traverse trees in an in-order fashion. The root is considered to be at the zeroth level. First, find the height of the tree and store it into res. res array store every smallest element in each level of a binary tree.
Input : 
           7
        /    \
       6       5
      / \     / \
     4  3     2  1  
      
Output : 
Every level minimum is
level 0 min is = 7
level 1 min is = 5
level 2 min is = 1

Smallest value in each level of Binary Tree: https://www.geeksforgeeks.org/smallest-value-level-binary-tree/

Read More