This is a work of art and beauty! There are people who can do but can't teach. Then there are those who can maybe teach but can't do. Then there are legends, who can do both at a mediocre level. And then God said, "Let Errichto be". 🙌. You make complex stuff seem so mind-blowingly simple! Can't thank you enough!
Watching you is almost like having a 1-1 lecture with you. It's as if you are empathetic to what the learner could think of next, and you answer in the next second (or more accurately, YOU enable the learner think the right way). I get the same experience when reading the book of Martin Kleppmann. I believe this is sth you see only from great explainers. Anyway, just wanted to share. Thanks for all the effort you put through your videos Errichto!
@@GGxEpsilon I think __lg belongs to the gcc compiler and is designed to work on integers (or long longs) specifically. log2 should have the same behaviour, but as Errichto mentions in the video: floating point values are scary to work with.
today i am practice codeforces Div2 C problem but i am not able to solve efficiently and seen editorial sparse table algorithm is used then learn this from your lecture then simply solve and learn this concept smart way very thankful for you explanation
Finally a video that perfectly explains the core concept. I was able to come up with log n approach before you explained and was so proud of myself. And then you dropped constant time which blew my mind. :D Thanks Errichto!
You are the best competitive programmer. Very thanks. I understood it very clearly. Thanks for spending a lot of time to explain us. Thank you Errichto!
This is very cool. Eager to learn about the segment tree. I didn't know about this. There surely are good use cases for this algorithm. For sure segment trees, or a similar structure, are used in databases.
Amazing tutorial, for so long I was not sure how queries take constant time and not logN time. I always thought we need to answer each queries such that we divide range into powers of 2... finally your tutorial solved that for me that we need to take largest power of 2 which fits in given range and check from L and R end point and hence it is O(1). thank you so much for clearing this :) Also this clears why we can't use sparse table for answering range sum queries in O(1) because we are using overlapping ranges, right?
I agree that using log2(x) is something to be avoided generally, however, if x < 2^31, it is guaranteed that the result of (int)log2(x) will be the same of any the bit tricks, so it might be a good choice if it's faster to code.
Please make detailed videos on segment tree and it various applications( like, min , max, updating, sum, frequency of max frequent element in the asked range etc...)
Search bitwise left shift and right shift on UA-cam Also i think errichto has a video on bit manipulation where he explained left shift and right shift
@@hitesh6856 It's O(1) rather than O(number of bits). CPU doesn't need to iterate bits one by one, it does it faster just like other basic operations like addition.
Can we use sparse table for sum queries if we use the method where we convert ranges to binary and add it like we do in binary lifting (query time = logN)?
Won’t the time complexity for answering a single query still logN as we are computing log2(len) where len is R - L + 1 which in worst case is of the order (N). So won’t the time complexity be logN per query?
He's the best competitive programmer in my opinion. He devotes so much to the community. Thankyou errichto!
Totally agree 😁
This is a work of art and beauty! There are people who can do but can't teach. Then there are those who can maybe teach but can't do. Then there are legends, who can do both at a mediocre level. And then God said, "Let Errichto be". 🙌. You make complex stuff seem so mind-blowingly simple! Can't thank you enough!
I think you're exaggerating but still - thank you!
That's crazy bro
This is the greatest tutorial I have ever seen, soo detailed and crystal clear!!!!!!
Thanks :)
The transition from logorithm to constant complexity for each query had put a smile. That was so cool.😎. Excellent explanation. Keep it going.
I agree that the transition is nice and satisfying.
Thanks for this amazing course. Your explanation is just in another level.
Watching you is almost like having a 1-1 lecture with you. It's as if you are empathetic to what the learner could think of next, and you answer in the next second (or more accurately, YOU enable the learner think the right way). I get the same experience when reading the book of Martin Kleppmann. I believe this is sth you see only from great explainers. Anyway, just wanted to share. Thanks for all the effort you put through your videos Errichto!
I was looking for sparse table tutorial. When I saw Errichto's video in the list, I knew I couldn't get any luckier.
c++ also has builtin function __lg for base-2 logs with integers. Nice and clear explanation (as always)!
Oh, right.
I think log2 does the same, doesnt it?
@@GGxEpsilon I think __lg belongs to the gcc compiler and is designed to work on integers (or long longs) specifically. log2 should have the same behaviour, but as Errichto mentions in the video: floating point values are scary to work with.
I don't understand anything you're saying, but your voice is so soothing like ASMR to me
Lmao, simp.
today i am practice codeforces Div2 C problem but i am not able to solve efficiently and seen editorial sparse table algorithm is used then learn this from your lecture then simply solve and learn this concept smart way very thankful for you explanation
Finally a video that perfectly explains the core concept. I was able to come up with log n approach before you explained and was so proud of myself. And then you dropped constant time which blew my mind. :D Thanks Errichto!
Errichto this is so nice and simple explanation I read it in book but did not understand you are really nice at explaining
You explain this beautifully, thank you so much
Hopes you comeback with more explaining video
He is really great and down to earth person....always willing to do something good for community....👍👍👍
i love learning from Errichto more than my own profs
You are the best competitive programmer. Very thanks. I understood it very clearly. Thanks for spending a lot of time to explain us. Thank you Errichto!
Read about sparse table 2 days back. I checked if you had made any video on it. And here it is. 💯
amazing dude, I've been following your videos for a year now and you are always improving the way u teach. thanks !
Let's hope that I will keep improving then :)
Woah explained so simple, seems like a complex math but it is not once you understand the intent behind thanks a lot for the video
Clear, concise, and perfect explanation
Please do some Videos on Data Structure.
Your explanations are simple and precise.
may you get all of what you want in life..i respect you
For computing "k" in the query function we can do k=floor(log2(len)) then we can have 2^k
This is very cool. Eager to learn about the segment tree.
I didn't know about this. There surely are good use cases for this algorithm. For sure segment trees, or a similar structure, are used in databases.
Best Explanation, you made it so easy to understand. Please keep up the good work 😊
Duma rozpiera, że rodak jest takim mózgiem :)
I don't know why people disliked this video.🤷♂️🤷♂️
plz do segment tree.. waiting for a long time..
Amazing tutorial, for so long I was not sure how queries take constant time and not logN time. I always thought we need to answer each queries such that we divide range into powers of 2... finally your tutorial solved that for me that we need to take largest power of 2 which fits in given range and check from L and R end point and hence it is O(1). thank you so much for clearing this :)
Also this clears why we can't use sparse table for answering range sum queries in O(1) because we are using overlapping ranges, right?
I agree that using log2(x) is something to be avoided generally, however, if x < 2^31, it is guaranteed that the result of (int)log2(x) will be the same of any the bit tricks, so it might be a good choice if it's faster to code.
Video quality and explanation is soo good.
Thank-you!!
Hello guys, I am errichto, is so cool to hear
Should have checked this out before, not knowing sparse tables cost me yesterday as the seg tree failed in time.
You never dissappoint!
Wow! its so clear even a 5 year old IQ guy lile me understands , Thank you for the wonderful content Ericchto !
that was indeed a really good explanation to sparse tables. Thank you for this video. :)
Wonderful video. Helped me a lot sir
Finally Errichto is back :)
Dzięki za pomoc w przygotowaniu do Olimpiady Informatycznej Juniorów (:
The brain on this man
Erichto you are the best person in the world!
Thank,I just needed this perfect and Crystal clear explanation .Orz
why it is k
you are wrong
Very nice explanation Errichto
I love even more your recent videos
Thanks ☺️ , this lecture was really helpful.
It would be nice if you covered CSES problemset. It has a lot of educational problems that are hard to solve if you don't know the right technique.
check out CPH. CSES is a supplementary problem set to that book. Good luck!
Please make detailed videos on segment tree and it various applications( like, min , max, updating, sum, frequency of max frequent element in the asked range etc...)
Can someone explain me what is “1
Search bitwise left shift and right shift on UA-cam
Also i think errichto has a video on bit manipulation where he explained left shift and right shift
Here you go :
ua-cam.com/video/xXKL9YBWgCY/v-deo.html
@@leviackerman9882 Tks u so much
It means 2 to the power k
Very nice explanation
Thank you for this great video
BTW : Is the __builtin function O(1) or O(log) or what ??
It is O(number of bits), so it is essentially O(1)
@@hitesh6856 It's O(1) rather than O(number of bits). CPU doesn't need to iterate bits one by one, it does it faster just like other basic operations like addition.
@@Errichto ohh. I didn't knew that. Thanks! big fan..!
@@Errichto thx for answering
Thank you, Errichto.
2 year's in and still waiting for the segment tree video
Amazing tutorial!!! Really enjoyed it and learned a lot!
This reminds of Reversort in Codejam Quali
Keep up these good tutorials. Thanks a lot
Errichto can you please make a video on how to deal with burnouts we face while constant coding?
10:00 this was when I started thinking that sparse tables are clever.
Is the condition in line 30, correct? It does not reflect m[i + (1
Thank you! Got mine working now! Awesome tutorial!
Easily explained.
Great explanation.
We can also solve this problem using sliding window concept in O(n) time
Amazing stuff, good explanation
He's sooo clever. Thanks for the video
Errichto orz ❤️
Hey Errichto, one question, what do you use in order to write your notes, i think you use like a tablet or something
please do segment trees next
Hi , can I know the name of program used to explain pls?
I saw this somewhere to find largest power of 2 less than or equal to n:
x=n
While(x&(x-1))
x&=x-1;
Now x will be the answer
Can we use sparse table for sum queries if we use the method where we convert ranges to binary and add it like we do in binary lifting (query time = logN)?
Won’t the time complexity for answering a single query still logN as we are computing log2(len) where len is R - L + 1 which in worst case is of the order (N). So won’t the time complexity be logN per query?
Can you have multiple overlapping intervals?
your balance bracket concept apply div2 B problem in contest get Accepted and my rank under 2500 thanks for you good job
:)
What balance bracket concept?
Could u pls share the link of that video 🙏🙏
ua-cam.com/video/piT58dNLPhg/v-deo.html
the best youtuber
Thanks for this vid - i like your background - so the goal to the get the O(N*log((N) + Q) though N is increasing tremendously ?
It's O(N*log(N) + Q) so it makes a lot of sense if Q is huge.
i dnno, this guy is godtier. I cannot compute. syntax error
How do you find problems on SPOJ? It seems so difficult to find by tags.
Many thanks!
legend.
I got WA with this code on spoj, do you guys have any ideas?
I feel smarter already....
Nice!! Binary is always Beautiful :)
Line 27, shouldn't it be i
It is like segment tree
How would we handle updates?
You need a segment tree for that.
What an explanation! op
pls do video on disjoint set union
Thanks You
Segment tree can also do the same right? So whats the advantage here?
Time complexity becomes O(N+Q*logN) and improves space complexity too
@@mohansharma-pt6yk in segment tree time complexity is O(QlogN)?
I can AC the cses problem but cant for the spoj :))
Please do make how and when u started doing cp. Love your videos from Bangladesh
Awesome!!
I have no idea what queries are, and i am trying to learn
❤
good !
💯💯💯
Amazing👍🏽👍🏽
You're amazing
awesome