LCA – Lowest Common Ancestor

Errichto Algorithms April 6, 2021
Video Thumbnail
Errichto Algorithms Logo

Errichto Algorithms

@errichto

About

Algorithms, competitive programming, coding interviews. I make educational videos and coding live streams, always sharing my thought process. My name is Kamil Dębowski (or Errichto) and I'm quite good at competitive programming. I'm a finalist of multiple big programming competitions like ICPC, Facebook Hacker Cup and Google Code Jam (even got 2nd place in 2018). I also organize competitions, which means inventing and preparing problems.

Video Description

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 https://youtu.be/oib-XsjFa-M SPOJ problem https://www.spoj.com/problems/LCASQ/ code https://github.com/Errichto/youtube/blob/master/lca.cpp 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 U-V". (I don't have a source for this one). Coding live streams - https://www.twitch.tv/errichto FAQ - https://github.com/Errichto/youtube/wiki/FAQ Subscribe for more educational videos on algorithms, coding interviews and competitive programming.

You May Also Like