Back to Browse

Binary Tree - 65: Find distance b/w two nodes in Binary Tree

20.2K views
Jan 3, 2020
12:05

Source Code:https://thecodingsimplified.com/find-distance-between-two-nodes-in-binary-tree/ Solution: - Find lca of these two values or nodes: https://www.youtube.com/watch?v=YRy5Ob4koL0 - Find distance from lca to 1st value = d1 - Find distance from lca to 2nd value = d2 - Now add both value, this is the distance - Time Complexity: O(n) - Space Complexity: O(1) Do Watch video for more info This Problem is synonym of following problems: binary tree find distance between two given values, binary tree find distance between two nodes, 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 - 65: Find distance b/w two nodes in Binary Tree | NatokHD