Be the first user to complete this post
|
Add to List |
Print All Nodes Between Two Given Levels
Objective: Given a binary Tree and two levels, Print all the nodes between those.
Input: A Binary Tree and two levels.
Output: Print all the nodes between given levels.
Example:

Approach:
- The solution of this problem is very simple, Do level order traversal and in recursive calls first add the right child and then left child.
- Take a global variable say, currLevel which will store the current level while doing Level Order traversal.
- Print only nodes between given levels.
Read this solution " Level Order Traversal, Print each level in separate line" and implement the above approach.
Also Read: