Heaps 4 TrickleDown

  Рет қаралды 14,968

RobEdwards

RobEdwards

Күн бұрын

Пікірлер: 17
@w0ndong
@w0ndong 5 жыл бұрын
way better than my current DS class... thx professor Edward ! !
@belwizdadimed3967
@belwizdadimed3967 5 жыл бұрын
Clear explanation but you should have used just an int[] array to avoid littering the code with generics comparable and hide the essential topic.
@Croccifixo
@Croccifixo 5 жыл бұрын
Isn't there a problem with the second if-statement? Consider the situation where right is indeed the last position, meaning there must also be a left child. If the right position is greater than parent, you always swap it, regardless of whether the left child is greater than right. In the case that the right child is last position, you should consider it as an internal node. Also, using greater than or equal to in the third if-statement is redundant, as you have already checked for equality, simply using strictly greater than is more accurate (and you will not need to check right, if a node doesn't have a left child, it wont have a right child, if it only has a left child, this is handled in the first if statement, and if it has both, it's an internal node). I would consider removing the second if statement and updating the condition of the third one to if (left > lastPosition)
@alexandercheprasov9048
@alexandercheprasov9048 4 жыл бұрын
Yep. I had the same comments when was watching it :)
@animeshkumar9593
@animeshkumar9593 4 жыл бұрын
Glad I found this comment. I was thinking the same while watching the video
@teetanrobotics5363
@teetanrobotics5363 5 жыл бұрын
Please make a playlist for algorithm design and analysis.
@Play-Date-Care
@Play-Date-Care 4 жыл бұрын
We always remove root, then trickle down, but what if the value we want to remove is not in the root, is some other node?
@lewisben6697
@lewisben6697 5 жыл бұрын
In the third case in TrickDown function, there should be no equal because the first two cases had discussed about it
@1Maestr00o3
@1Maestr00o3 5 жыл бұрын
wouldn't the second if statement be better like this: if(right == lastPosititon && array[parent] < array[right] && array[left] < array[right]){ swap(parent, right); return; }else if(right == lastPosititon && array[left] > array[parent]){ swap(parent, left); return; } ?
@monickverma2944
@monickverma2944 4 жыл бұрын
it's same
@ahmidahmid9303
@ahmidahmid9303 5 жыл бұрын
the remove is complicated function
@kubuspat9729
@kubuspat9729 5 жыл бұрын
Tell me, what about the statement where the parent is bigger than his childs. Where is statement for that case? // i answear that question for myself xD ( there won't be such a case )
@philspaghet
@philspaghet 6 жыл бұрын
Algorithm doesn't work, the if conditions make it exit loop early
@Play-Date-Care
@Play-Date-Care 6 жыл бұрын
I'm thinking the same, would the recursive call happen inside of the if loop?
@potatorun3541
@potatorun3541 6 жыл бұрын
the return statement in if conditions is only reached when left or right as already at last position.
@Croccifixo
@Croccifixo 5 жыл бұрын
@@potatorun3541 if right is last position, it might cause a heap violation, but that is only because of the second if-statement (consider adding a 17 as the last node in the video before trickleDown, the second if-statement will swap 17 and 11, causing 17 to be a parent to 22 and ending the recursion)
Heaps 5 HeapSort
8:43
RobEdwards
Рет қаралды 68 М.
Hashes 1 Introduction
15:36
RobEdwards
Рет қаралды 40 М.
«Жат бауыр» телехикаясы І 26-бөлім
52:18
Qazaqstan TV / Қазақстан Ұлттық Арнасы
Рет қаралды 434 М.
Trees  and heaps 1 Introduction
4:13
RobEdwards
Рет қаралды 20 М.
How to Remember Everything You Read
26:12
Justin Sung
Рет қаралды 3,8 МЛН
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 287 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Think Fast, Talk Smart: Communication Techniques
58:20
Stanford Graduate School of Business
Рет қаралды 44 МЛН
Heaps, heapsort, and priority queues - Inside code
19:01
Inside code
Рет қаралды 110 М.
Heaps 1 Introduction and Tree levels
5:44
RobEdwards
Рет қаралды 25 М.
I just tried o3-mini
6:31
ThePrimeTime
Рет қаралды 232 М.