Get real, active and permanent YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

LCA – Lowest Common Ancestor

Follow
Errichto Algorithms

Tutorial on LCA algorithm. We use Binary Lifting to get O(N*log(N)) preprocessing and O(log(N)) to find the lowest common ancestor of two nodes in a tree.
Binary Lifting video    • Binary Lifting (Kth Ancestor of a Tre...  
SPOJ problem https://www.spoj.com/problems/LCASQ/
code https://github.com/Errichto/youtube/b...
Two homework problems:
1) Answer queries "find distance between two given nodes U and V" https://cses.fi/problemset/task/1135
2) Given a tree with weighted edges (i.e. every edge has some value), answer queries "given two nodes U and V, find minimum weight along path UV". (I don't have a source for this one).

Coding live streams   / errichto  
FAQ https://github.com/Errichto/youtube/w...
Subscribe for more educational videos on algorithms, coding interviews and competitive programming.

posted by v4leries8d