Be the first user to complete this post

  • 0
Add to List

55. Print Nodes Between Two Levels in Binary Tree

Objective: The objective of this task is to print all the nodes of a binary tree that lie between two specified levels.


Print All Nodes Between Two Given Levels
Print All Nodes Between Two Given Levels


  • To solve this problem, we perform a level-order traversal of the binary tree.
  • During the traversal, we keep track of the current level using a global variable, currLevel.
  • Nodes are printed only if they lie between the specified levels.
Print all nodes between nodes 2 and 3
10 15
20 25 30 35

For further reference, you can read about the solution in the "Level Order Traversal" article and implement the approach discussed above.