Heaps & Priority Queues - Heapify, Heap Sort, Heapq Library - DSA Course in Python Lecture 9

  Рет қаралды 23,016

Greg Hogg

Greg Hogg

Күн бұрын

Пікірлер: 49
@GregHogg
@GregHogg 5 ай бұрын
Master Data Structures & Algorithms For FREE at AlgoMap.io!
@steventolerhan5110
@steventolerhan5110 3 ай бұрын
Best video on heaps on youtube fr fr
@Brusselsprouts2023
@Brusselsprouts2023 Ай бұрын
wow! This channel is so underrated. Thankyou!!
@TaskForce141br
@TaskForce141br 29 күн бұрын
On the pop is important that you substitute the top element by the rightmost element on the heap, that way you maintain the balance property of the heap, after that you heapify down. The way it was presented may cause confusion, beacause if you just remove the element on the top and do the rearranjement, the heap may become unbalanced
@Dan-codes
@Dan-codes 3 күн бұрын
Excellent explanation, thank you
@sonhoang8986
@sonhoang8986 2 ай бұрын
Thank you for your explanation. I love how you explain the theory, but I expected more about the coding section. I hope something from scratch to understand the theory. Anw, thank you so much
@Jay-ek7uw
@Jay-ek7uw 5 ай бұрын
These videos are great. Much love Greg
@kapilrules
@kapilrules 4 ай бұрын
thank you man to negate the values to use it as max heap was awesome trick ❤❤❤
@GregHogg
@GregHogg 4 ай бұрын
Yeah I found that very cool when I first learned it too
@jonasjanaitis436
@jonasjanaitis436 24 күн бұрын
Great explanation.Thank you
@karamalrasam1606
@karamalrasam1606 3 ай бұрын
thank you so much for your clear explaination👍👍
@updownftw
@updownftw 21 күн бұрын
Greg you missed the complete binary tree property of Heap at 5:20
@garythegoat8341
@garythegoat8341 2 ай бұрын
What would happen if that -10 was a leaf node when you were heapifying the min heap? The leaf nodes were ignored but presumably in that case that -10 would need to get to the top?
@jingwen888wang
@jingwen888wang Ай бұрын
The pop heap described h err e is incorrect, as it does not maintain the heap property which has the has the leaf nodes filled from left, so it messes up the array structure essentially, please pay attention to the details and correct it if it causes confusions.
@adventurer2395
@adventurer2395 2 ай бұрын
0:15 bro hitting puberty lol. Great video, well explained
@Emivvvvv
@Emivvvvv Ай бұрын
looool 😂
@Abzal-pd9ri
@Abzal-pd9ri 5 ай бұрын
Thank you a lot !! Please more videos like that
@davenuada527
@davenuada527 3 ай бұрын
What app do you use to draw on?
@ahmedzz4754
@ahmedzz4754 5 ай бұрын
Can't wait to see the dp or backtracking lesson (my national programming contest is soon and I suck a both)
@phaseyon5825
@phaseyon5825 Ай бұрын
how was it
@gaberhassan3972
@gaberhassan3972 2 ай бұрын
very nice,👌👌👌👌 Thanks
@navneetkumar9377
@navneetkumar9377 4 ай бұрын
Quick question : How are you able to print the trees beautifully at 14:47 ? I can't find any inbuilt function.
@user-jm6gp2qc8x
@user-jm6gp2qc8x 3 ай бұрын
he didn't
@erons_xo
@erons_xo 14 күн бұрын
Your tree at 11:55 doesn't satisfy the condition of a heap as the last level wasn't filled from left to right
@ibraheem_Zain
@ibraheem_Zain 5 ай бұрын
that was very helpful and clear thanks man you really great ♡♡
@GregHogg
@GregHogg 5 ай бұрын
Glad to hear it, thanks so much!
@WilkinARuiz
@WilkinARuiz Ай бұрын
Would heapq. Be ok to use in a coding interview? Wouldn't they want you to implement the code?
@godcomplex8251
@godcomplex8251 2 ай бұрын
Hey greg, wouldn't the Heapify function be O(n.log(n)), since for every node in the tree of N nodes, you need to perform "Sift down" which itself is O(log(n))?
@sitrucz
@sitrucz Ай бұрын
No look for a proof. O(n)
@devshah6634
@devshah6634 5 ай бұрын
23:45 You said the heap is set according to the smallest frequency. So why is (3,4) placed after (4,5) in the heap array? PS: Started watching this course recently, loving it so far!
@raafayhemani2018
@raafayhemani2018 3 ай бұрын
The heap array is an array representation of a tree, if you wanted to get them in order you'd do a heapsort
@asagiai4965
@asagiai4965 5 ай бұрын
15:36 I thought heap pop have time complexity of 0(1)? Since you are just popping the minimum or the maximum (depends on what type of heap you have) at the top.
@GregHogg
@GregHogg 5 ай бұрын
Nope, peek has O(1) but to pop you need to fix the tree which is log n
@asagiai4965
@asagiai4965 5 ай бұрын
@GregHogg ok I see there's a difference.
@add-I4d-e9p
@add-I4d-e9p 5 ай бұрын
I feel so bad about watching this great DSA lesson for free so even though I have access to Wi-Fi, I use my mobile data instead. (This won't help you in any way either haha TT) My daily DSA teacher Greg ^_^b
@Karandeepsingh-kk2rv
@Karandeepsingh-kk2rv 5 ай бұрын
Could you do a course on linked lists please?
@godcomplex8251
@godcomplex8251 2 ай бұрын
Actually I just looked this up in Sedgewick algo book, it says that heap construction is n.log(n)...
@DevendraYadav-pw9vp
@DevendraYadav-pw9vp 2 ай бұрын
you are correct there is mistake just taking the position to correct spot is O(long) and for this to all n will extend the overall complexity to O(nlogn)
@godcomplex8251
@godcomplex8251 2 ай бұрын
@GregHogg Love your videos but you should really correct or address mistakes like this, otherwise this can affect your credibility...
@leandrormor
@leandrormor 5 ай бұрын
thanks for sharing your view, i appreciate it
@GregHogg
@GregHogg 5 ай бұрын
You're very welcome!
@leandrormor
@leandrormor 5 ай бұрын
not your view, but your way of teaching
@dfhg315
@dfhg315 5 ай бұрын
684. Redundant Connection can u make video on this problem
@atanumaiti16
@atanumaiti16 4 ай бұрын
when u added 13 to the heap, it violates complete binary tree property.i think it should be added as right child of node 7. same goes with -2.
@sitrucz
@sitrucz Ай бұрын
It’s not a binary tree. Order of children don’t matter.
@asagiai4965
@asagiai4965 5 ай бұрын
I'm surprised that idk that heaps and priority queues are same thing. Always thought they are different.
@GregHogg
@GregHogg 5 ай бұрын
Haha yep!
@qulinxao
@qulinxao 5 ай бұрын
sorry but in "real" pq only one(or zero) node have 1 child - others ether 0 or 2 - it simplifay :)
Heaps, heapsort, and priority queues - Inside code
19:01
Inside code
Рет қаралды 103 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
APEC 12/21: Vacuum Propeller, Torsion Physics & CID Demo
4:49:35
Alt Propulsion
Рет қаралды 1,8 М.
2.6.3 Heap - Heap Sort - Heapify - Priority Queues
51:08
Abdul Bari
Рет қаралды 2,2 МЛН
Top K Elements in 6 minutes | LeetCode Pattern
6:23
AlgoMasterIO
Рет қаралды 3 М.
Top K Frequent Elements - Leetcode 347 - Heaps (Python)
14:08
Greg Hogg
Рет қаралды 13 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 660 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 387 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН