Sparse Table & RMQ (Range Minimum Query)

  Рет қаралды 81,070

Errichto Algorithms

Errichto Algorithms

Күн бұрын

Пікірлер: 138
@ayushgaba7089
@ayushgaba7089 3 жыл бұрын
He's the best competitive programmer in my opinion. He devotes so much to the community. Thankyou errichto!
@Thy_panda_king
@Thy_panda_king 3 жыл бұрын
Totally agree 😁
@utkarshdevgan6199
@utkarshdevgan6199 3 жыл бұрын
This is the greatest tutorial I have ever seen, soo detailed and crystal clear!!!!!!
@Errichto
@Errichto 3 жыл бұрын
Thanks :)
@vishnusingh4118
@vishnusingh4118 3 жыл бұрын
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!
@Errichto
@Errichto 3 жыл бұрын
I think you're exaggerating but still - thank you!
@gsscala
@gsscala 5 ай бұрын
That's crazy bro
@saikumarganganapalli5957
@saikumarganganapalli5957 3 жыл бұрын
The transition from logorithm to constant complexity for each query had put a smile. That was so cool.😎. Excellent explanation. Keep it going.
@Errichto
@Errichto 3 жыл бұрын
I agree that the transition is nice and satisfying.
@loonshott
@loonshott 10 ай бұрын
Thanks for this amazing course. Your explanation is just in another level.
@berfubuyukoz353
@berfubuyukoz353 7 ай бұрын
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!
@magnuseifr
@magnuseifr 3 жыл бұрын
c++ also has builtin function __lg for base-2 logs with integers. Nice and clear explanation (as always)!
@Errichto
@Errichto 3 жыл бұрын
Oh, right.
@GGxEpsilon
@GGxEpsilon 3 жыл бұрын
I think log2 does the same, doesnt it?
@magnuseifr
@magnuseifr 3 жыл бұрын
@@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.
@rajd7002
@rajd7002 3 жыл бұрын
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!
@mrdude1084
@mrdude1084 3 жыл бұрын
I was looking for sparse table tutorial. When I saw Errichto's video in the list, I knew I couldn't get any luckier.
@nighteagle6297
@nighteagle6297 3 жыл бұрын
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!
@sureshchaudhari4465
@sureshchaudhari4465 3 жыл бұрын
Errichto this is so nice and simple explanation I read it in book but did not understand you are really nice at explaining
@BrunoSouza-wy2et
@BrunoSouza-wy2et 3 жыл бұрын
amazing dude, I've been following your videos for a year now and you are always improving the way u teach. thanks !
@Errichto
@Errichto 3 жыл бұрын
Let's hope that I will keep improving then :)
@asifanwarsajid8332
@asifanwarsajid8332 3 жыл бұрын
Read about sparse table 2 days back. I checked if you had made any video on it. And here it is. 💯
@__agpatel__
@__agpatel__ 3 жыл бұрын
He is really great and down to earth person....always willing to do something good for community....👍👍👍
@vietnguyenquoc4948
@vietnguyenquoc4948 4 ай бұрын
You explain this beautifully, thank you so much Hopes you comeback with more explaining video
@anshusingh2473
@anshusingh2473 3 жыл бұрын
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
@ayamtaken2580
@ayamtaken2580 3 жыл бұрын
I don't understand anything you're saying, but your voice is so soothing like ASMR to me
@vaibhavtiwari6540
@vaibhavtiwari6540 3 жыл бұрын
Lmao, simp.
@farhan787
@farhan787 3 жыл бұрын
Finally Errichto is back :)
@gauravupreti9340
@gauravupreti9340 2 жыл бұрын
Best Explanation, you made it so easy to understand. Please keep up the good work 😊
@manjuender6286
@manjuender6286 3 жыл бұрын
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
@joserenteria5899
@joserenteria5899 3 жыл бұрын
i love learning from Errichto more than my own profs
@sourandbitter3062
@sourandbitter3062 3 жыл бұрын
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.
@hitesh6856
@hitesh6856 3 жыл бұрын
Video quality and explanation is soo good. Thank-you!!
@kxb6098
@kxb6098 3 жыл бұрын
Clear, concise, and perfect explanation
@anowlwithinternet9125
@anowlwithinternet9125 9 ай бұрын
You never dissappoint!
@glaucoa.9214
@glaucoa.9214 3 жыл бұрын
Erichto you are the best person in the world!
@rishabhkalra9505
@rishabhkalra9505 3 жыл бұрын
that was indeed a really good explanation to sparse tables. Thank you for this video. :)
@CrystalSergeant
@CrystalSergeant 3 жыл бұрын
I love even more your recent videos
@vwv.1d
@vwv.1d 2 жыл бұрын
may you get all of what you want in life..i respect you
@ashisharyan3028
@ashisharyan3028 3 жыл бұрын
Thank,I just needed this perfect and Crystal clear explanation .Orz
@coefficient1359
@coefficient1359 3 жыл бұрын
Very nice explanation Errichto
@iftekharfahim
@iftekharfahim 3 жыл бұрын
Please do some Videos on Data Structure. Your explanations are simple and precise.
@mjKeszely
@mjKeszely 3 жыл бұрын
Duma rozpiera, że rodak jest takim mózgiem :)
@hiderr6805
@hiderr6805 3 жыл бұрын
Dzięki za pomoc w przygotowaniu do Olimpiady Informatycznej Juniorów (:
@houcyhoucy3486
@houcyhoucy3486 4 күн бұрын
Excellent! Which whiteboard tool do you use to draw on on screen? It seems great.
@sameerbamnaha2189
@sameerbamnaha2189 3 жыл бұрын
Amazing tutorial!!! Really enjoyed it and learned a lot!
@subarnodatta2181
@subarnodatta2181 3 жыл бұрын
Wonderful video. Helped me a lot sir
@ahmmedsakibnoman2849
@ahmmedsakibnoman2849 3 жыл бұрын
plz do segment tree.. waiting for a long time..
@5590priyank
@5590priyank 3 жыл бұрын
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?
@atharvasalokhe5168
@atharvasalokhe5168 3 жыл бұрын
Hello guys, I am errichto, is so cool to hear
@Vikash_Art
@Vikash_Art 3 жыл бұрын
For computing "k" in the query function we can do k=floor(log2(len)) then we can have 2^k
@AnkitJosh
@AnkitJosh 3 жыл бұрын
Thanks ☺️ , this lecture was really helpful.
@userrand4900
@userrand4900 Жыл бұрын
Is the condition in line 30, correct? It does not reflect m[i + (1
@tripleaplusb2214
@tripleaplusb2214 3 жыл бұрын
Hi , can I know the name of program used to explain pls?
@vineethkumar8132
@vineethkumar8132 3 жыл бұрын
Wow! its so clear even a 5 year old IQ guy lile me understands , Thank you for the wonderful content Ericchto !
@priceandpride
@priceandpride 3 жыл бұрын
The brain on this man
@beaujamo
@beaujamo Жыл бұрын
Thank you! Got mine working now! Awesome tutorial!
@i_am_wiz
@i_am_wiz Жыл бұрын
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?
@ejackkulation7377
@ejackkulation7377 2 жыл бұрын
Thank you, Errichto.
@josealejandrovaroncarreno1692
@josealejandrovaroncarreno1692 3 жыл бұрын
the best youtuber
@madhvansharma5917
@madhvansharma5917 2 жыл бұрын
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)?
@MehbubulHasanAlQuvi
@MehbubulHasanAlQuvi 3 жыл бұрын
Keep up these good tutorials. Thanks a lot
@pavankumar-cy6mg
@pavankumar-cy6mg 3 жыл бұрын
why it is k
@xiangli9588
@xiangli9588 2 жыл бұрын
you are wrong
@learning7517
@learning7517 2 жыл бұрын
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.
@manas_singh
@manas_singh 3 жыл бұрын
How do you find problems on SPOJ? It seems so difficult to find by tags.
@plosslaw
@plosslaw 3 жыл бұрын
Amazing stuff, good explanation
@therealcdubbb8040
@therealcdubbb8040 3 жыл бұрын
Can you have multiple overlapping intervals?
@isma--
@isma-- 2 жыл бұрын
Hey Errichto, one question, what do you use in order to write your notes, i think you use like a tablet or something
@simonstrandgaard5503
@simonstrandgaard5503 3 жыл бұрын
Great explanation.
@siddharthmagadum16
@siddharthmagadum16 3 жыл бұрын
He's sooo clever. Thanks for the video
@vali8924
@vali8924 3 жыл бұрын
Very nice explanation
@joshuawilson6907
@joshuawilson6907 Жыл бұрын
I got WA with this code on spoj, do you guys have any ideas?
@GGxEpsilon
@GGxEpsilon 3 жыл бұрын
Errichto orz ❤️
@ankitvats3295
@ankitvats3295 3 жыл бұрын
What an explanation! op
@nileshchandra6435
@nileshchandra6435 3 жыл бұрын
Should have checked this out before, not knowing sparse tables cost me yesterday as the seg tree failed in time.
@subarnodatta2181
@subarnodatta2181 3 жыл бұрын
I don't know why people disliked this video.🤷‍♂️🤷‍♂️
@QngTu1159
@QngTu1159 3 жыл бұрын
Can someone explain me what is “1
@leviackerman9882
@leviackerman9882 3 жыл бұрын
Search bitwise left shift and right shift on KZbin Also i think errichto has a video on bit manipulation where he explained left shift and right shift
@leviackerman9882
@leviackerman9882 3 жыл бұрын
Here you go : kzbin.info/www/bejne/romufWyPd7yaebs
@QngTu1159
@QngTu1159 3 жыл бұрын
@@leviackerman9882 Tks u so much
@apoorvmehra121
@apoorvmehra121 3 жыл бұрын
It means 2 to the power k
@rohitoze9359
@rohitoze9359 2 жыл бұрын
Line 27, shouldn't it be i
@parashararamesh4252
@parashararamesh4252 3 жыл бұрын
How would we handle updates?
@Errichto
@Errichto 3 жыл бұрын
You need a segment tree for that.
@shivam6829
@shivam6829 3 жыл бұрын
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...)
@kongzilla2897
@kongzilla2897 3 жыл бұрын
Nice!! Binary is always Beautiful :)
@jakoolaboo
@jakoolaboo 3 жыл бұрын
Thank you for this great video BTW : Is the __builtin function O(1) or O(log) or what ??
@hitesh6856
@hitesh6856 3 жыл бұрын
It is O(number of bits), so it is essentially O(1)
@Errichto
@Errichto 3 жыл бұрын
@@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.
@hitesh6856
@hitesh6856 3 жыл бұрын
​@@Errichto ohh. I didn't knew that. Thanks! big fan..!
@jakoolaboo
@jakoolaboo 3 жыл бұрын
@@Errichto thx for answering
@srishtikdutta8946
@srishtikdutta8946 3 жыл бұрын
Awesome!!
@Dima-Teplov
@Dima-Teplov 3 жыл бұрын
Many thanks!
@shrikantpadhy6125
@shrikantpadhy6125 3 жыл бұрын
Segment tree can also do the same right? So whats the advantage here?
@mohansharma-pt6yk
@mohansharma-pt6yk Жыл бұрын
Time complexity becomes O(N+Q*logN) and improves space complexity too
@skt7088
@skt7088 Жыл бұрын
@@mohansharma-pt6yk in segment tree time complexity is O(QlogN)?
@apoorvmehra121
@apoorvmehra121 3 жыл бұрын
Amazing👍🏽👍🏽
@shaoxiongduan
@shaoxiongduan 3 жыл бұрын
legend.
@milepivo
@milepivo 3 жыл бұрын
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.
@KuaisArts
@KuaisArts 3 жыл бұрын
check out CPH. CSES is a supplementary problem set to that book. Good luck!
@BGOPC
@BGOPC 11 ай бұрын
2 year's in and still waiting for the segment tree video
@darshankubavat1764
@darshankubavat1764 3 жыл бұрын
Errichto can you please make a video on how to deal with burnouts we face while constant coding?
@joshuawilson6907
@joshuawilson6907 Жыл бұрын
I can AC the cses problem but cant for the spoj :))
@skullcode8856
@skullcode8856 3 жыл бұрын
10:00 this was when I started thinking that sparse tables are clever.
@rishabhpurwar4875
@rishabhpurwar4875 3 жыл бұрын
You're amazing
@Steve168xyz
@Steve168xyz 3 жыл бұрын
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 ?
@Errichto
@Errichto 3 жыл бұрын
It's O(N*log(N) + Q) so it makes a lot of sense if Q is huge.
@nishant5249
@nishant5249 3 жыл бұрын
We can also solve this problem using sliding window concept in O(n) time
@gnet888
@gnet888 3 жыл бұрын
Thanks You
@p4rzival127
@p4rzival127 3 жыл бұрын
This reminds of Reversort in Codejam Quali
@aakashvishwakarma4653
@aakashvishwakarma4653 3 жыл бұрын
💯💯💯
@tihomirjovicicify
@tihomirjovicicify 3 жыл бұрын
awesome
@anshusingh2473
@anshusingh2473 3 жыл бұрын
your balance bracket concept apply div2 B problem in contest get Accepted and my rank under 2500 thanks for you good job
@Errichto
@Errichto 3 жыл бұрын
:)
@puneetgoel7416
@puneetgoel7416 3 жыл бұрын
What balance bracket concept? Could u pls share the link of that video 🙏🙏
@anshusingh2473
@anshusingh2473 3 жыл бұрын
kzbin.info/www/bejne/ppq3Zmuag7GDnsk
@dhakad22klx
@dhakad22klx Жыл бұрын
Easily explained.
@asdfinonebody4103
@asdfinonebody4103 3 жыл бұрын
good !
@koushiksaigopalamalladi5994
@koushiksaigopalamalladi5994 3 жыл бұрын
pls do video on disjoint set union
@Shirolicious
@Shirolicious 3 жыл бұрын
i dnno, this guy is godtier. I cannot compute. syntax error
@shnerdz
@shnerdz 3 жыл бұрын
please do segment trees next
@nisarggogate8952
@nisarggogate8952 3 жыл бұрын
Hey in preprocessing part inner for loop should be for(i=0;i+(1
@imRJD14
@imRJD14 Ай бұрын
what a sexy explanation
@anonymoussloth6687
@anonymoussloth6687 2 жыл бұрын
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
@shalinisingh8688
@shalinisingh8688 3 жыл бұрын
@MehbubulHasanAlQuvi
@MehbubulHasanAlQuvi 3 жыл бұрын
First View, Like and Comment
Prefix Sums - Problems, Code in C++ & Python
20:51
Errichto Algorithms
Рет қаралды 59 М.
Binary Exponentiation
15:13
Errichto Algorithms
Рет қаралды 103 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
C++ Bitsets in Competitive Programming
15:35
Errichto Algorithms
Рет қаралды 122 М.
Sparse Table Algorithm Range Minimum Query
27:33
Tushar Roy - Coding Made Simple
Рет қаралды 59 М.
Segment Tree (Implementation)
1:18:46
Errichto Hard Algorithms
Рет қаралды 35 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 574 М.
Computations Modulo P in Competitive Programming
18:15
Errichto Algorithms
Рет қаралды 128 М.
Matrix Exponentiation + Fibonacci in log(N)
31:23
Errichto Algorithms
Рет қаралды 71 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 157 М.
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 613 М.
Sparse Table Data Structure
23:18
WilliamFiset
Рет қаралды 32 М.
LCA - Lowest Common Ancestor
15:56
Errichto Algorithms
Рет қаралды 64 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН