LCA – Lowest Common Ancestor

preview_player
Показать описание
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.
Two homework problems:
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).

Subscribe for more educational videos on algorithms, coding interviews and competitive programming.
Рекомендации по теме
Комментарии
Автор

Here are two homework problems for you:
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).

Errichto
Автор

Generally, it is difficult to learn from extra-ordinary people like you. But you are exception to that also. Thank you so much.

allwell
Автор

After watching numerous errichto videos, whenever I explain my code to anyone else I get errichto's accent.
Your videos are awesome.

beastfromeast-wd
Автор

I am simple man, i see Errichto is teaching something i will click it

ksg
Автор

Errichto should be in the UN protected list ❤.

coefficient
Автор

The analogy with binary search was a great hint what we are going to do here. Thanks Errichto

sonugupta
Автор

It's a great initiative by you to teach algorithms. Looking forward for more such great videos. Also add some more practice problems of whatever you explain.

ShubhamKumar-mexy
Автор

YES! A THOUSAND TIMES YES! Thank you much for making a video on LCA!

hydroUNI
Автор

I know how to do LCA with RMQ, but this solution is something else
I love it to bits 💚💚

alexandruhritcan
Автор

Errichto one of the best, I love his videos.

glaucoa.
Автор

This guy doing a god's work...whoever is the god of cp

desyfer
Автор

I know that these problems are very easy for you but trust me these are very hard for me.
And if you are making it, I will watch it!. You are literal GOD in coding!.
Please keep on making these very basic videos on concepts, I really liked your Binary Search video as well!.
Thanks

RajatSingh-dgov
Автор

The way you explained the binary lifting is just awesome ❤❤

saitejaballa
Автор

Thanks for the lectures. I like this format a lot: short videos with explanation, code, and example.

bethsuni
Автор

Can't believe this still *F R E E*

iPaperPlane
Автор

The preprocessing of vector<vector<int> up will take O(Nlog(N)) time so how this solution TC is O(logN)

prathamkumar
Автор

His voice and explanation both are soothing🙂

itz_me_imraan
Автор

Some of your videos(like this one) are so well made. Thnx🔥

saiprasadduduka
Автор

awesome explanation of LCA and Binary Lifting

josephwong
Автор

Thank you i was searching for this after the binary lifting video 👍

simone