Binary Tree - 62: Check if given two nodes are siblings in Binary Tree
Source Code:https://thecodingsimplified.com/check-if-given-two-nodes-are-siblings-to-each-other-in-binary-tree/ Solution: - To find if two given nodes are siblings or not, we need to check of given two nodes should be left or right of any node. - We'll traverse tree in pre order manner. - If value is null or equal to root value, then we'll return true - While traversing, when we're at particular node, we'll check if given nodes exists either with left & right. - If we can't find the value in tree, it'll return false - Time Complexity: O(n) - Space Complexity: O(1) Do Watch video for more info This Problem is synonym of following problems: binary tree check if given two nodes are siblings, check if given two nodes are siblings in binary tree, check if two nodes are siblings 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.