Heaps & Priority Queues in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ม.ค. 2025

ความคิดเห็น • 38

  • @alexneigh7089
    @alexneigh7089 19 วันที่ผ่านมา +2

    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.

    • @NeuralNine
      @NeuralNine  19 วันที่ผ่านมา +1

      Glad to hear it helps! :)

  • @dhbroad2660
    @dhbroad2660 2 ปีที่แล้ว +8

    Thank you for this! So many other videos on heaps just speak about the theory, but don't show any implementation or manipulation.

  • @Gooloso98
    @Gooloso98 2 ปีที่แล้ว +14

    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).

  • @MaybeGriffin
    @MaybeGriffin 5 หลายเดือนก่อน +1

    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?

  • @soufianeaitlhadj9115
    @soufianeaitlhadj9115 5 หลายเดือนก่อน +3

    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.

  • @rafaelsartoricavalcante4253
    @rafaelsartoricavalcante4253 ปีที่แล้ว

    Best video on subject, thanks

  • @vikasjha1064
    @vikasjha1064 6 หลายเดือนก่อน

    Brilliant mate, ,Please make these type of explanation for other Data Structure also.
    Thanks

  • @servantofthelord8147
    @servantofthelord8147 6 หลายเดือนก่อน

    Thank you!

  • @takshdhabalia1476
    @takshdhabalia1476 2 ปีที่แล้ว

    Great video
    Loved the content
    Keep it up

  • @anthonyrojas9989
    @anthonyrojas9989 10 หลายเดือนก่อน

    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

  • @adarshsasidharan254
    @adarshsasidharan254 2 ปีที่แล้ว

    Brilliant video

  • @disrael2101
    @disrael2101 2 ปีที่แล้ว +5

    What for / where it's used for mainly

    • @jerrylin4980
      @jerrylin4980 2 ปีที่แล้ว

      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.

    • @Pickolzi
      @Pickolzi 11 หลายเดือนก่อน +2

      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.

    • @disrael2101
      @disrael2101 10 หลายเดือนก่อน

      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

    • @AryanSingh-eq2jv
      @AryanSingh-eq2jv 10 หลายเดือนก่อน +5

      free palestine

    • @disrael2101
      @disrael2101 10 หลายเดือนก่อน

      in ur dreams :DD@@AryanSingh-eq2jv

  • @abhishekpardeshi5701
    @abhishekpardeshi5701 8 หลายเดือนก่อน

    you did not mention priority queue code

  • @tcgvsocg1458
    @tcgvsocg1458 2 ปีที่แล้ว

    can you do a video on screen recorder but no import with vanilla pyhton please

  • @홍성의-i2y
    @홍성의-i2y ปีที่แล้ว

    valid heap: 2:12 of th-cam.com/video/hkyzcLkmoBY/w-d-xo.html
    => parent should be smaller than children (min-heap).

  • @soniahandle
    @soniahandle ปีที่แล้ว

    hi, can someone explain what "maintaining heap invariant" means?

  • @lzdps
    @lzdps 2 ปีที่แล้ว

    awesome!

  • @digvijaynadimetla9934
    @digvijaynadimetla9934 2 ปีที่แล้ว +1

    devudivi sami

  • @AKProductionsTelugu
    @AKProductionsTelugu 5 หลายเดือนก่อน

    Put the fucking mic closer to you

  • @AryanSingh-eq2jv
    @AryanSingh-eq2jv 10 หลายเดือนก่อน

    i love you

  • @niteshanthony2324
    @niteshanthony2324 2 ปีที่แล้ว +25

    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

    • @dheerajsharma355
      @dheerajsharma355 ปีที่แล้ว +6

      Hare Krishna!!

    • @Mr_Clumsee
      @Mr_Clumsee ปีที่แล้ว +8

      Jai Shree Ram!!

    • @mrsteth993
      @mrsteth993 ปีที่แล้ว +8

      Jesus isn't real.

    • @caio-jl6qw
      @caio-jl6qw ปีที่แล้ว +4

      Bot

    • @epsi.mp3
      @epsi.mp3 ปีที่แล้ว +10

      stop advertising jesus in a python tutorial