Binary Tree - 61: Get Sibling of given value in Binary Tree
Source Code:https://thecodingsimplified.com/get-sibling-node-of-a-given-value-in-binary-tree/ Solution: - To find siblings node of a given value, our main is to find the given value. - We'll traverse tree in pre order manner. - If value is null or equal to root value, then sibling node will be null - While traversing, when we're at particular node, we'll check if given value exists either with left or right. If given value matches to left, we return the right node. If it matches to right node value, we return the left node. - If we can't find the value in tree, it'll return null - Time Complexity: O(n) - Space Complexity: O(1) Do Watch video for more info This Problem is synonym of following problems: binary tree get sibling node of given value, get sibling of a value 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 formatsNo download links available.