Created
December 25, 2022 05:30
-
-
Save thmain/5ca4605dde8d439ea5e1dfccca04e3a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const printNodesAtLevelK = (root, k) => { | |
if (root === NULL) { | |
return; | |
} | |
if (k === 0) { | |
console.log(`Node at Level k = ${root.data}`); | |
return; | |
} else { | |
printNodesAtLevelK(root.left, k-1); | |
printNodesAtLevelK(root.right, k-1); | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment