Back to Browse

Binary Tree - 67: Print all nodes at K distance from Leaf Node in Binary Tree

7.4K views
Jan 7, 2020
21:38

Source Code:https://thecodingsimplified.com/print-elements-at-k-distance-from-leaf-node-in-binary-tree/ Solution: - Traverse binary tree recursively & keep on inserting element value in int array & set false value in visited boolean array - when you encounter leaf node, print the 'current index - k'th index value from array & set the value in boolean array to true for this index - Time Complexity: O(n) - Space Complexity: O(n) Do Watch video for more info This Problem is synonym of following problems: binary tree Print elements at K distance from Leaf Node in Binary Tree, Print elements at K distance from Leaf Node in Binary Tree in Binary Tree, coding simplified, CHECK OUT CODING SIMPLIFIED https://www.youtube.com/codingsimplified ★☆★ VIEW THE BLOG POST: ★☆★ http://thecodingsimplified.com I started my YouTube channel, Coding Simplified, during Dec of 2015. Since then, I've published over 200+ videos. ★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★ https://www.youtube.com/codingsimplified?sub_confirmation=1 ★☆★ Send us mail at: ★☆★ Email: [email protected]

Download

0 formats

No download links available.

Binary Tree - 67: Print all nodes at K distance from Leaf Node in Binary Tree | NatokHD