Back to Browse

Binary Tree - 66: Print all nodes at k distance from given node in Binary Tree

16.7K views
Jan 4, 2020
19:41

Source Code:https://thecodingsimplified.com/print-all-nodes-at-k-distance-from-given-node-in-binary-tree/ Solution: - Traverse binary tree recursively & find targetNode - Once targetNode is found, we've two direction to solve the question - Element present in down direction, we'll print element by using the same problem as 'print all element at given level k' - For up direction, we take help of each ancestor till end & keep on printing the element. - Time Complexity: O(n) - Space Complexity: O(1) Do Watch video for more info This Problem is synonym of following problems: binary tree Print all nodes at k distance from given node, Print all nodes at k distance from given node 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 - 66: Print all nodes at k distance from given node in Binary Tree | NatokHD