How to insert in a Max Heap in Java ? | Implementation

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 2024

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

  • @itsdineshvaryani
    @itsdineshvaryani  3 ปีที่แล้ว

    Please *Like* , *Comment* , *Share* , *Subscribe* and *Click Bell* 🔔🔔🔔 Icon for More Updates. To get *Data Structures and Algorithms* complete course for free please follow this link - th-cam.com/play/PL6Zs6LgrJj3tDXv8a_elC6eT_4R5gfX4d.html

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

    Best series for DS & Algo. I am also 10 yrs java exp guy. Was looking for DS & Algo free course over TH-cam with java implementation and found this. Hats Off To You Man...Excellent Work. GOD BLESS YOU :)

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

    In resize function , you started for loop with i=0 ,it should be i=1 right?

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

      I think you are right

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

      actually heap[0] = null, thus it wont matter.
      same will be copied to temp[].

  • @harshitsaluja3493
    @harshitsaluja3493 3 ปีที่แล้ว +2

    Sir I am not able to find the delete node from Max heap video in the playlist.Can you please upload it that would be very helpful

  • @rajarishabhsingh8296
    @rajarishabhsingh8296 2 ปีที่แล้ว +3

    Sir you didn't change the capacity it's still 3 but size has been printed in ur console as 6 but while I did the same it printed ArrayIndexOutOfBoundException ...when I provided capacity of 6 then it's size was printed ...why sir .please make it clear.

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

      Take it as an exercise and figure out why !!!

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

      I think when capacity is 3 and when it is completed it calls resize method. Even if you give capacity 2 it shows the same output.

  • @nikhilreddy7298
    @nikhilreddy7298 3 ปีที่แล้ว +1

    I loved your teaching :)

    • @itsdineshvaryani
      @itsdineshvaryani  3 ปีที่แล้ว +1

      Thanks !!! I request you to please share this playlist with ur friends and colleagues. It will help channel grow and motivate me to create more such videos !!!

    • @nikhilreddy7298
      @nikhilreddy7298 3 ปีที่แล้ว +1

      @@itsdineshvaryani Sure man... Hope you're videos will reach it to many developers out in the world❤️

  • @SanthoshHugar
    @SanthoshHugar 3 ปีที่แล้ว +2

    Why is the method named swim() ? Should it be swap() ?

    • @itsdineshvaryani
      @itsdineshvaryani  3 ปีที่แล้ว +1

      There are various names given to it ... You can give any name ... Just that method name lets u know algo behind it !!!

    • @SanthoshHugar
      @SanthoshHugar 3 ปีที่แล้ว +1

      @@itsdineshvaryani Sure. Thanks. I am binge watching your Data Structure and Algorithms playlist. Very well explained. Thanks for the videos.

    • @itsdineshvaryani
      @itsdineshvaryani  3 ปีที่แล้ว +1

      Thanks !!! I request you to share it with ur friends and colleagues so that it helps channel grow and motivate me to add more !!!

    • @SanthoshHugar
      @SanthoshHugar 3 ปีที่แล้ว +1

      @@itsdineshvaryani Definitely I will.

  • @vasudevparmar9876
    @vasudevparmar9876 3 ปีที่แล้ว +2

    Why we are using integer[] heap instead of int[] heap

    • @itsdineshvaryani
      @itsdineshvaryani  3 ปีที่แล้ว +2

      int has default values which may interfere with heap properties ... For demo i have taken Integer as it has null value as default.

    • @vasudevparmar9876
      @vasudevparmar9876 3 ปีที่แล้ว +2

      @@itsdineshvaryani okay got it
      Using integer I will have output like:- null 5 4 3 2 1 null null
      But using int output will be like:- 0 5 4 3 2 1 0 0

    • @itsdineshvaryani
      @itsdineshvaryani  3 ปีที่แล้ว +1

      @@vasudevparmar9876 yes ... Exactly

    • @technicaljethya993
      @technicaljethya993 3 ปีที่แล้ว

      @@itsdineshvaryani i don't think so because we are only working with the index 1 to n in the heapify algo so whether it is 0 or null it doesn't really matter.

    • @itsdineshvaryani
      @itsdineshvaryani  3 ปีที่แล้ว

      @@technicaljethya993 yes but when u print array u wont get from where to where heap lies ...