Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node {
- char val;
- Node left, right;
- }
- public void printLevel(Node root, int level) {
- printLevel(root, level, 0);
- }
- public void printLevel(Node root, int levelToPrint, int currLevel) {
- if (currLevel == levelToPrint) {
- System.out.print(root.val);
- }
- else {
- printLevel(root.left, levelToPrint, currLevel + 1);
- printLevel(root.right, levelToPrint, currLevel + 1);
- }
- }
Add Comment
Please, Sign In to add comment