Data Structures & Algorithms using JavaScript Course
Data Structures & Algorithms using JavaScript
/
Advanced

Lowest Common Ancestor

Definition

Finding the lowest node in T that has both nodes p and q as descendants. In a BST, this is O(log N). In a generic binary tree, it requires O(N) DFS.

Explain Like I'm New

Finding the closest shared relative (e.g. a shared Grandfather) between two distant cousins.

Interactive Coding Challenges

LCA of Binary Tree

Solution Code

Loading...
Console output will appear here...