I am a distance learner, and for me such vids are extremely valuable. It feels like real university lectures when I was younger, with quite a few advantages in comparison.
nice video, remind me of data structures classes. min heap its great and efficient. Usually its implemented on top of arrays, although its best viewed as graphs. min heap always keep a min height state since the height of the tree generated will be log2(numbers inside).
I want just to point out that the heap for a given set of numbers is "NOT" Unique. So you can always predict that if you apply the "heapify()' to the same set of numbers, it can result in different answers.
I am still new to this topic but I will try to explain why I believe it is better to use heaps. Say you have a list of 10,000 elements and that you always need the lowest or highest number. If you are constantly adding and removing elements from the array, after each append() or pop(), you will need to sort the list to maintain the order of the list. 1. Using list.sort() will at worst case run in O(n*logn) run time 2. iterating through each item of the list to find the proper position to place the new element will at worst case run in O(n) run time 3. inserting an element in a heap will at worst case run in O(logn) run time So to insert a new element into a 10,000 element array and maintain order would take 1. ~130,000 iterations for list.sort() 2. ~10,000 iterations for iterating the array 3. ~14 iterations for a heappush() So imagine you have 10,000 people trying to buy tickets online, each person has a rank depending on previous activity. You can store their data in a tuple (rank, user_id). So when tickets start to become available for sale and the website wants to prioritize higher ranked customers, using a heap will allow the website to run a lot faster especially with a large audience.
cool thanks for the explanation, it makes sense only the math formula i didn't understand as you didn't explain what each parameter means.. also what's the equalivent of heap in js? as i work with js for webapps@@Pickolzi
Hey everyone ik its pretty late but i just wanna tell u all to take it easy, relax, pray to GOD and have and trust in GOD as well as believe in his one and only son Jesus and to repent of your sins. hope u have an amazing day
I am a distance learner, and for me such vids are extremely valuable. It feels like real university lectures when I was younger, with quite a few advantages in comparison.
Glad to hear it helps! :)
Thank you for this! So many other videos on heaps just speak about the theory, but don't show any implementation or manipulation.
nice video, remind me of data structures classes.
min heap its great and efficient.
Usually its implemented on top of arrays, although its best viewed as graphs.
min heap always keep a min height state since the height of the tree generated will be log2(numbers inside).
Love the videos. You seem like the guy to ask out of the channels I've watched, and recommendations on ultra learning in terms of python?
I want just to point out that the heap for a given set of numbers is "NOT" Unique. So you can always predict that if you apply the "heapify()' to the same set of numbers, it can result in different answers.
Best video on subject, thanks
Brilliant mate, ,Please make these type of explanation for other Data Structure also.
Thanks
Thank you!
Great video
Loved the content
Keep it up
Your videos are awesome, but the music is loud af in the beginning and then the voice audio is way lower. I think that could be better
Brilliant video
What for / where it's used for mainly
When you need to insert and retrieve multiple times while the order of the list needs to be maintain, I think it's good to use a heap.
I am still new to this topic but I will try to explain why I believe it is better to use heaps.
Say you have a list of 10,000 elements and that you always need the lowest or highest number. If you are constantly adding and removing elements from the array, after each append() or pop(), you will need to sort the list to maintain the order of the list.
1. Using list.sort() will at worst case run in O(n*logn) run time
2. iterating through each item of the list to find the proper position to place the new element will at worst case run in O(n) run time
3. inserting an element in a heap will at worst case run in O(logn) run time
So to insert a new element into a 10,000 element array and maintain order would take
1. ~130,000 iterations for list.sort()
2. ~10,000 iterations for iterating the array
3. ~14 iterations for a heappush()
So imagine you have 10,000 people trying to buy tickets online, each person has a rank depending on previous activity. You can store their data in a tuple (rank, user_id). So when tickets start to become available for sale and the website wants to prioritize higher ranked customers, using a heap will allow the website to run a lot faster especially with a large audience.
cool thanks for the explanation, it makes sense only the math formula i didn't understand as you didn't explain what each parameter means.. also what's the equalivent of heap in js? as i work with js for webapps@@Pickolzi
free palestine
in ur dreams :DD@@AryanSingh-eq2jv
you did not mention priority queue code
can you do a video on screen recorder but no import with vanilla pyhton please
valid heap: 2:12 of th-cam.com/video/hkyzcLkmoBY/w-d-xo.html
=> parent should be smaller than children (min-heap).
hi, can someone explain what "maintaining heap invariant" means?
invariant = unchanging, immutable.
awesome!
devudivi sami
Put the fucking mic closer to you
i love you
Hey everyone ik its pretty late but i just wanna tell u all to take it easy, relax, pray to GOD and have and trust in GOD as well as believe in his one and only son Jesus and to repent of your sins. hope u have an amazing day
Hare Krishna!!
Jai Shree Ram!!
Jesus isn't real.
Bot
stop advertising jesus in a python tutorial