AlgorithmsThread 9: Treaps!

  Рет қаралды 24,453

SecondThread

SecondThread

Күн бұрын

Пікірлер: 59
@carbon13
@carbon13 4 жыл бұрын
The mirroring portion outside was an extremely nice touch.
@randomdude-kr4in
@randomdude-kr4in 4 жыл бұрын
What a day to be alive. Can't wait to watch!
@rohangarg5473
@rohangarg5473 4 жыл бұрын
Thank you David for all the effort you put in making solution videos, screencast and lectures. Just a small suggestion or I should say Request, Kindly do lectures on not so advanced stuff with questions. Just like what you did for tree algorithms(problems on gym + explanation later), that was really helpfull. It would be really great if you could do for other topics as well(not so advanced topics) which can be helpfull and at the same time, frequently used in cf contests. Topics like:- Dp with bitmask Dp on segments Some dp problems which can be solved with recur + memo Graphs Tree dp Array problems increasing decreasing subsequence types. Etc Some gym questions + explanation later would be Great, just the way you did for tree algorithms. Thank you so much
@maximilianoredigonda8645
@maximilianoredigonda8645 4 жыл бұрын
Had this resource be available in my good ol' ICPC times 🔥 hahaha nice job!
@askdf
@askdf 3 жыл бұрын
Great video SecondThread! Really looking forward to using treaps in my upcoming contests! :^)
@LeoLeo-nx5gi
@LeoLeo-nx5gi 4 жыл бұрын
Ohh Holy, I was wandering everywhere to understand this topic since months, pls do take some problems and pls let us walk through the code step by step ❤️
@igorlukyanov7434
@igorlukyanov7434 Жыл бұрын
Your videos are both funny and interesting. I absolutely love them!
@joacarrilloco
@joacarrilloco 4 жыл бұрын
Looking for a good treap tuto long ago. Nice video and gonna check out the problems! Thanks
@rivaille8867
@rivaille8867 4 жыл бұрын
Thanks for this great tutorial and codeforces problem set , appreciate what you are doing
@imranfarid8186
@imranfarid8186 4 жыл бұрын
Tbh, I was kind of scared when you brought that axe!:)
@1732ashish
@1732ashish 4 жыл бұрын
I have been waiting to learn one of the balanced search trees and treap seems like a good starting point, I will be thankful if you can mention that case you talked about where you might explicitly need splay trees ?
@jonathanharmeyer2255
@jonathanharmeyer2255 4 жыл бұрын
"Host" David Harmeyer. Woooaahhhh, hold up
@BleedingKnight
@BleedingKnight 4 жыл бұрын
Great tutorial David. I had two questions though. 1) Since treaps are randomized, what would be some safe constraints in contest problems for which treaps won't reach a height much worse than log(N) and timeout due to that? 2) Since the left to right order is preserved, I guess the relative order of any split up treaps of a larger treap cannot be changed while merging as it won't remain a BST. So I was wondering is there any efficient way to shuffle the order of the elements in a segment (like cyclically shift the segment right by 1) and do range queries on the modified order of elements? EDIT: Nvm about 2. To cyclically shift l...r to one right, we can just mirror l..r and then mirror l+1...r
@SecondThread
@SecondThread 4 жыл бұрын
You don't need to maintain the BST property either. The left to right order is only based on how you merge things, the example in the beginning was just to explain why it was randomized. As for constraints, you're probably safe up to about 2*10^5 but you might need a big time limit depending on how costly your internal operations are.
@BleedingKnight
@BleedingKnight 4 жыл бұрын
​@@SecondThread Oh okay. But now if we don't maintain the relative order, isn't it possible that the height of the tree changes from logn to something much worse over a lot of queries? For example, if we have n updates where we split treap T at first n - 1 positions getting T1 and T2 as the new treaps and then merge in the order T2 and T1 to form T again, wouldn't this become much worse than logn height eventually? EDIT: Solved the gym contest's A problem. I guess it doesn't.
@mehulgoel5875
@mehulgoel5875 4 жыл бұрын
wow, I'm amazed at your intelligence, the speed you have in solving codeforces problems is wow too, it doesn't even seem you need to think hard about them at all
@martonnemeth236
@martonnemeth236 3 жыл бұрын
Nice explanation! :)
@weirongwu4964
@weirongwu4964 4 жыл бұрын
Awesome video! Thanks David! What laptop do you use? Is this the surface pro? Love how you can draw ideas and diagrams out to help you visualize difficult concepts.
@SecondThread
@SecondThread 4 жыл бұрын
I actually use a desktop and have a cheap drawing tablet on from Amazon. It doesn't have a screen or anything, so I'm looking at my monitor, but my hand is just on my desk
@weirongwu4964
@weirongwu4964 4 жыл бұрын
@@SecondThread Interesting. Thanks David!
@nuni_boyka7869
@nuni_boyka7869 4 жыл бұрын
Loved the video awesome!
@tanishqgupta1071
@tanishqgupta1071 4 жыл бұрын
He haven't uploaded yet 😂
@nuni_boyka7869
@nuni_boyka7869 4 жыл бұрын
@@tanishqgupta1071 doesn't matter my comment would have been same.
@erray7546
@erray7546 4 жыл бұрын
@@nuni_boyka7869 SecondThread orz
@dontony7071
@dontony7071 4 жыл бұрын
Sir please attend the Div 2 round🥺.Missing your post contest explanations now a lot.
@YASH_KHICHARIYA
@YASH_KHICHARIYA 3 ай бұрын
8:43 Why will it get splitted into 1/3 and 2/3 on average?
@ДимаАртюхов-э6щ
@ДимаАртюхов-э6щ 4 жыл бұрын
Hey, what's up! Are planning to do solutions for last Techno Cup round 2021? If so, I can't wait to see that)
@nallasivakrishna5693
@nallasivakrishna5693 4 жыл бұрын
The video is awesome.Clearly understood the concept. @second thread could you please provide solutions for codeforces 678 div2 round. It would be really helpful.Thanks in advance.
@jitendrapandey176
@jitendrapandey176 4 жыл бұрын
Come on David ..come on 🔥🔥
@mikerega7724
@mikerega7724 4 жыл бұрын
You're the best I hope and one day compete with you why I know what will happen Nothing is impossible
@fuadalhasan1784
@fuadalhasan1784 4 жыл бұрын
Hey good morning.. 😊
@dhairyapurohit8065
@dhairyapurohit8065 4 жыл бұрын
Hey brother if possible please make video on codeforces round 679(tecnicup once) specifically problem C div2 Perform Easily Kind of hard to understand from Tutorial part✌️ thank you
@shzaizzhang4465
@shzaizzhang4465 4 жыл бұрын
Thanks.
@thallium54
@thallium54 4 жыл бұрын
In C++, using a vector to store the nodes is faster than pointers.
@thallium54
@thallium54 4 жыл бұрын
My implementation: github.com/thallium/acm-algorithm-template/blob/master/code/DataStructure/Treap_split.cpp
@SecondThread
@SecondThread 4 жыл бұрын
That's pretty clean. I like the pass-by-reference so you don't forget to update your treap root
@xinyuan127
@xinyuan127 4 жыл бұрын
Wow, thank you :3
@shubhampokhriyal8491
@shubhampokhriyal8491 4 жыл бұрын
Goood morning everybody 😻😻although night is going on
@satishshingade8514
@satishshingade8514 4 жыл бұрын
very nice
@RifatulIslam__
@RifatulIslam__ 4 жыл бұрын
C++ code was helpful
@hadva2
@hadva2 4 жыл бұрын
Just a general guestion about Java: why do you, while doing competitive programming, put all methods to static? Wouldn't be simpler to just run an instance of the class in the main method and then not need to set everything to static (or is the execution faster with everything on static?).
@SecondThread
@SecondThread 4 жыл бұрын
Yeah, it might be shorter to code. Conceptually I like to save objects for when they are actually in an object of something though; it just makes more sense to me.
@nicktohzyu
@nicktohzyu 2 жыл бұрын
can treap do stabbing queries like segment tree? which is the problem that requires splay and not treap? why have the two children as `vector` rather than `Treap *left, *right` ?
@SecondThread
@SecondThread 2 жыл бұрын
1) What's a stabbing query? You can do a range query of width 1 if that's what you mean 2) Nothing with a splay tree is *impossible* with a treap, but some things are a log factor slower. An example of this is implementing a Link Cut Tree. That's like the main and only one I know of. 3) So that you can flip left and right really easily. If you access your kids as kids[0^flip], this will always access the *left* kid even when you need to propogate a flip still.
@mikaoj317
@mikaoj317 4 жыл бұрын
is it possible to get ur scanner class?
@puedoamarte
@puedoamarte 4 жыл бұрын
Do more algorithms please
@satishshingade8514
@satishshingade8514 4 жыл бұрын
good everybody
@namitaa
@namitaa 2 жыл бұрын
sir u are fine
@tsyetsye7689
@tsyetsye7689 4 жыл бұрын
Please be my sensei David....orz....!!!!!
@ritwizsinha1261
@ritwizsinha1261 4 жыл бұрын
YAYYAYYAYA
@akashchandra2223
@akashchandra2223 4 жыл бұрын
how did you get so smart, are you naturally inclined
@mehulgoel5875
@mehulgoel5875 4 жыл бұрын
I think he is. Even I find him mind boggling quick in seeing through the problem to the solution. And watching him in action inspires me to atleast try to emulate it. Feels similar to how I felt after watching the movie and tv series "Limitless".
@karanb2067
@karanb2067 4 жыл бұрын
I thought the video said "meap"...whatever tho, good usage of time!
@ishanpatni2684
@ishanpatni2684 4 жыл бұрын
Please share your java template
@tabletalenovo9695
@tabletalenovo9695 3 жыл бұрын
Bruh how tf do u do that palindrome problem
@iprakhar22
@iprakhar22 4 жыл бұрын
"Finding daddy" hmm ok
@MohitYadav-yv2rw
@MohitYadav-yv2rw 4 жыл бұрын
Yummy!!!
@sathvikkuthuru7804
@sathvikkuthuru7804 4 жыл бұрын
orz
@madhukiranattivilli2321
@madhukiranattivilli2321 2 жыл бұрын
I'm sorry! Ur MERGE explanation wasn't understandable at all! U shud've used names to the nodes, or some other style to narrate. U were talking about priorities but u didn't assign any priorities to the nodes while explaining the concept (as an illustration). I hope I'll understand better while watching ur code section.
Treaps Contest Solutions
43:51
SecondThread
Рет қаралды 3,9 М.
8 Data Structures Every Programmer Should Know
17:09
ForrestKnight
Рет қаралды 113 М.
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
HOOOTDOGS
Рет қаралды 2,1 МЛН
РОДИТЕЛИ НА ШКОЛЬНОМ ПРАЗДНИКЕ
01:00
SIDELNIKOVVV
Рет қаралды 4 МЛН
Synyptas 4 | Арамызда бір сатқын бар ! | 4 Bolim
17:24
"كان عليّ أكل بقايا الطعام قبل هذا اليوم 🥹"
00:40
Holly Wolly Bow Arabic
Рет қаралды 9 МЛН
AlgorithmsThread 3: Segment Trees
43:40
SecondThread
Рет қаралды 29 М.
How I animate 3Blue1Brown | A Manim demo with Ben Sparks
53:41
3Blue1Brown
Рет қаралды 633 М.
Episode 30 - Treaps
1:06:42
Algorithms Live!
Рет қаралды 21 М.
A&DS S02E06. Treaps, implicit keys
1:17:56
Pavel Mavrin
Рет қаралды 3,2 М.
Treaps: A Fantastic Data Structure
6:13
NaderEG
Рет қаралды 294
The unexpected probability result confusing everyone
17:24
Stand-up Maths
Рет қаралды 716 М.
Just enough C to have fun
39:29
Kay Lack
Рет қаралды 54 М.
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
HOOOTDOGS
Рет қаралды 2,1 МЛН