Lecture 74: Heaps in C++ || Heap Sort || Insertion/Deletion in Heap || Priority Queue STL

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

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

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

    attendance ++ aandd consistency ++,aur bahot mazha araha hai,completed 160 questions on leetcode since january 1

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

    Hey bhagwan jii babbar bhaiya jesa dedication aur consistency dedo apne goal ke liye 👌🙏🔥

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

    in deletion there should one condition should also mention arr[leftIndex]

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

      yepp,this code is right bro

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

      thanks a lot you too bhaiya

    • @PratikD-dy4yo
      @PratikD-dy4yo ปีที่แล้ว +1

      exactly.... !

    • @anshikajain3298
      @anshikajain3298 ปีที่แล้ว +9

      if you use if statements only instead of if and else if then you will get the correct answer

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

      Thank you buddy :)

  • @avishkarpatil5871
    @avishkarpatil5871 9 หลายเดือนก่อน +4

    Hey everyone, just wanted to point out a small mistake in the code demonstrated in the tutorial.
    In the heapify function, when checking the conditions for left and right children, it should be leftchild

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

    I have started advanced dsa so many times from different sources and channels but this time the understanding is of next level thanks a lot bhaiya

  • @rahulpanjwani8449
    @rahulpanjwani8449 ปีที่แล้ว +86

    I think there will be one more condition in deletion for checking that if left is also greater than right or if right is greater than left in else if.
    One more thing when we are checking the bound in that it should be less than equal to.
    The correct code for deletion will be
    void deletefromHeap()
    {
    if(size==0)
    {
    cout

    • @HridoyHasan-j5b
      @HridoyHasan-j5b 11 หลายเดือนก่อน

      leftIndex

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

      I do agree 👍👍

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

      Bcoz without equal sign we will miss the last child bcoz we have already decremented the size above in the code
      @@HridoyHasan-j5b

    • @deveshgupta2931
      @deveshgupta2931 10 หลายเดือนก่อน +9

      One more correction when we are checking leftindex

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

      Even this is not going to work in case of example :- 10 7 6 5 2

  • @ritiksharma-im6dx
    @ritiksharma-im6dx 2 ปีที่แล้ว +7

    I never enjoyed coding ...but after following your course ..now icoding becomes my habit .thanks a lot bhaia

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

    Eagerly waiting for this!!! Thank you so much Bhaiya for covering this topic ♥️💯💯

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

    la jawab! simply magnificent! boht hi nazakat se ek jattil vishya ko suljhaya!

  • @DilipKumar-dv7zd
    @DilipKumar-dv7zd 9 วันที่ผ่านมา +1

    You men, nailed it, i have started and left multiple time DSA just because i i did not find the way i was looking to be taught but you men made it exactly what i was looking empowering to write code yourself just by the concept explanation, the barrier of language does not comes into picture once the concept is rock solid. Hats off.

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

    25:02 Deletion logic me you swapped with whichever of the two children are greater.
    28:30 Code: compares with either left or, later, right. If left one is greater (even if not greater than right) then that case will run.
    Suppose tree was 52 53 54 50, then code would make it 53 52 54 50 and not 54 53 52 50.
    Koi baat nhi hume logic samajh aa gya👍

    • @Ranjankumar-ik4vf
      @Ranjankumar-ik4vf 2 ปีที่แล้ว +1

      Yes

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

      yes

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

      for the second one , dono me if statements use hue hai, so agar pehla wala true hota hai, to pehla wala largest hoga, uske baad wo dusre wale k saath pehla compare hoga because wo already largest ho chuka hai,

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

      *DELETION CORRECT CODE WITH EACH EDGE CASE
      void dlt ()
      {
      if ( size == -1 )
      {
      cout

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

      ye jo tree hai 52 53 54 50,, ---> ye kisi heap property ko follow hae nahi krrha nither minheap nor maxheap toh isko pehle ek heap property ka tree banao, scondly haan there is error in thr code for deletion. we need to compare leftchild and rightchild before saying who is the greatest of them

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

    correction in the deletion method - compare the leftIndex and rightIndex, then swap the greater one if it is greater than parent.

    • @ankitkumar-ri2oh
      @ankitkumar-ri2oh 2 ปีที่แล้ว +2

      correct bro

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

      can u pls send me the correct code

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

      @@suratnu4609 void deleteFromHeap(){
      if(size==0){
      cout

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

      @@rajeevkumaryadav6948
      // Simpler one
      void deleteh()
      {
      if (size == 0)
      {
      cout

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

      @@ashhariqbalshanu thanks for help bro

  • @janvisharma2377
    @janvisharma2377 8 หลายเดือนก่อน +3

    Best DSA playlist ever, thank you so much for helping us.😍😍❤❤

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

    Itna achy sy Heap ko sari youtube py kisi ny nahi samjhaya...You are great Sir. Thanks for this amazing series.

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

    Love you babbar bhai....... Ham Garibo ke liye IT MEANS ALOT

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

    I think there's a mistake in Heapify Algorithm, the right condition should be right

    • @AtulSharma-sr9wi
      @AtulSharma-sr9wi 2 ปีที่แล้ว +2

      index is start from 0 so given ans is correct.

    • @KKK-bn3ez
      @KKK-bn3ez ปีที่แล้ว

      yes. I just discovered it myself also. Glad to see someone also been practicing and finding errors also.

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

      @@AtulSharma-sr9wi starting index is taken 1 from the beginning of the video, were u on weeds while taking the lecture ?

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

      Thanks for pointing out bro

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

    //For those who are struggling with deletion code, this is the correct one
    //The problem is with the condition (index

    • @shivam.mandhotra
      @shivam.mandhotra ปีที่แล้ว

      great job bruh!

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

      if left==size then right==size+1, so arr[right] should not be compared with arr[left]

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

      still wrong

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

      it is wrong.

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

      heap wala code bhi galat hai kya bhai ?

  • @SupriyoGhosh-gz3fs
    @SupriyoGhosh-gz3fs 7 หลายเดือนก่อน +1

    You guys are the ones, for whom we cse students can survive.

  • @debajyatibanerjee5480
    @debajyatibanerjee5480 ปีที่แล้ว +90

    I think #LoveBabbar did a slight mistake while writing the deletion method. We should do some slight modification in that code...
    void deleteRoot(){
    if(size==0){
    cout

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

      i was also stuck at this

    • @AyushmanTiwari-u6o
      @AyushmanTiwari-u6o ปีที่แล้ว +3

      Thanks u r the saviour

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

      thank you later . uwuw

    • @cheems08213
      @cheems08213 ปีที่แล้ว +17

      still wrong, in modification 1's if condition you are accessing arr[rightInd] without checking rightIndex

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

      Literally you save my time, thanks❤❤

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

    while(codehelp==babbar){
    learning ++;
    cout

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

    it feels good to continue watching the whole series and completed this many lectures thank you bhaiya for providing us this amazing series free of cost.

    • @vj270-o6v
      @vj270-o6v ปีที่แล้ว +1

      Are you able to solve leetcode questions?

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

    consistency again high hai bhaiya dono ki.........thanks.

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

    The best explanation of heaps out here in C++. Such great content !!!

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

    Maza aagya bhaiya... Thanks to this course... Ab contest me bhi questions solve ho rhe hai... 3 months pehle he coding seekhni start ki thi aapke saath... Thanks again !!!!!❤❤❤❤

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

    bhaiya... 1 saal baad is video dekhne aaya hoon.. kuki bhul gya hoon heapify function
    But ye wala look me aapko firse dekh ke maza aagya sachi bata rha hoon
    😅😍😍

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

    I can't thank you enough bhaiya for this amazing series.. this series is helping me a lot to polish my skills. You are a great teacher and blessing to us ⭐

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

    Literally sometimes I feel u r god behind this face.... Thnkuu so much for all your teaching 🙏🙏🙏🙏

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

    Thanks brothers , Our bangladeshi Coders really depends on the guys like you

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

    I never enjoyed coding ...but after following your course ..now icoding becomes my habit .thanks a lot bhaia #love babbar

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

    Laal phool pila phool Love bhaiya beautiful. Jokes apart tbh I really think he is such a cool person. Amazing explanation. Easy to understand.

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

    amazing video bhayya
    Learnt:
    1.insertion
    2.deletion
    3.heapify or build heap
    4.sort heap
    5.using stl priority queue >>max heap and min heap ;

  • @venkateshpk7822
    @venkateshpk7822 7 หลายเดือนก่อน +1

    your content and explanation just awesome bhaiya.
    Some guys just notice one mistake and keep barking abt that without knowing how much effort you put for one lecture

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

    I don't have words to express about ur dedication & hardworking. Tusi great ho great babar bhaiya

  • @HARRY-xz1hf
    @HARRY-xz1hf ปีที่แล้ว

    Babbar bhai thanks a lot. Mujhe kabhi nahi laga tha mai array k alawa kuch samajh bhi sakunga but after watching your videos I can't believe I have started solving Hard level DSA questions on leetcode. Thank you so much brother.

  • @msabhinavchandra4174
    @msabhinavchandra4174 9 หลายเดือนก่อน +3

    29:16 it's better to keep leftIndex

    • @SreevalliB-zv7qy
      @SreevalliB-zv7qy 8 หลายเดือนก่อน

      yes, actually. I don't understand why he's isn't checking those cases. He wrote it wrong?

    • @avinashr6100
      @avinashr6100 22 วันที่ผ่านมา

      Exactly

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

    wahh bhiyaa mza aa gya ekdum jabardast...subkuch samaj aya mereko......thanks bhiya love u

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

    the way you explain things is great because you cover all the details in your lecture.

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

    THANKYOU SO MUCH BHAIYA FOR THE AWESOME VIDEOS,SAB SMZH AA GYA Attendance ++ and Consistency ++

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

    I love you babbar bhaiyya... doing heap revision and still everything is crystal clear...

  • @Hidden..03
    @Hidden..03 2 ปีที่แล้ว +3

    Ek no. bhiya we dont want animation but the quality content.....my concept getting stronger day by day....i will watch more 2 videos of heap question and please upload hash in upcoming week so that i can study that topic.

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

    Welcome back bhaiya with great consistency

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

    Right now I am watching your 74th lecture , Tq for this course Bhaiya 🤘

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

    The BEST explanation of heaps on the internet, Great video

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

    really , i have watched almost all the available videos on heap but you explained everything about heap and in great way , thankyou for this effort

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

      is heap structure is created only using arrays ? no need to create nodes like in tree ?

  • @verma_jay
    @verma_jay ปีที่แล้ว +61

    Correct Deletion Logic:
    int index = 1;
    while(index < size){
    int leftIndex = 2 * index;
    int rightIndex = 2 * index + 1;
    int swapIndex = index;
    if(leftIndex

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

    In deletion , we are not firstly comparing left and right child to find which is max ,we are simply uisng if else, if left greater than a[i] , we are swaping a[i] with left and due to if else , we are not comparing a[i] with right child , so little confusion in deletion code

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

      yes its not right you run for other test case. use heapify function instead to put new root at right position'

    • @AjayYadav-um1oj
      @AjayYadav-um1oj 2 ปีที่แล้ว +5

      @@KazHachiOreki You are wrong bro there is problem in deletion : After deleting first element if parent is 30 leftchild 40 rightchild 50 and according to code we are swapping with leftchild then parent 40 leftchild 30 rightchild still 50 (here rightchild is greater than parent which is not a heap) so we have to take max of left and right child before swapping ;
      please clarify if i am wrong ;

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

      yes to my understanding the parent node should swap the largest value among left and right child. Thus a comparison b/w left and right child value is necessary

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

    you are the best teacher Bhaiya ,Really Your video is awesome

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

    A like is not enough justify the efforts and quality of this video. Thanks.

  • @Its_._aayush
    @Its_._aayush ปีที่แล้ว

    The way you teach is unstoppable. you are amazing teacher💯💯❤‍🔥❤‍🔥❤‍🔥

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

    present marked sir ,getting motivation from your consistency level, aag laga diye bhaiya aap..

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

    I learned all topic from start this dsa course very help full beginner level to high level because small concet point to point understand by love babbar bhaiya so again thanks bhaiya for free course .
    this best explanation for heap topc in c++.

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

    Awesome Explanation sir ji.. No one has covered these advanced topics so bautifully.😇

  • @cyro_-ej6xm
    @cyro_-ej6xm 7 หลายเดือนก่อน

    thanks luv babbar 💛 couldnt find any better way to understand heaps than this , respect++

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

    One of the Best lecture on Heap Topic .ThankYou Bhaiya 🙂

  • @jamitkumar7251
    @jamitkumar7251 26 วันที่ผ่านมา

    best dsa course on yt, no comparison bro 🔥🔥

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

    Thanks for explaining such typicall topic in such a easy way...🤩🤩

  • @ShivamKumar-hf5ec
    @ShivamKumar-hf5ec ปีที่แล้ว +1

    29:00 deletion logic a little change
    just to check in left or right which one is greater
    void delHeapEle() {
    if(size == 0) {
    cout

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

    currently watching lecture 40.... Amazing series bhaiya!! 😍😍🙏🙏

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

    Best DSA course on youtube !!👍

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

    probably the best course for dsa in youtube thanks a lot bhaiya

  • @Aman-fz1ew
    @Aman-fz1ew ปีที่แล้ว

    tagda video ,
    everything explainded very clearly with clear logic and code .

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

    One of the finest explanations. May God bless you.

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

    this course is the best dsa course in the country

  • @nikhilnagar4891
    @nikhilnagar4891 3 หลายเดือนก่อน

    Thank sir kl lab me que solve hai or aaj aapse pura heap padh liya❤❤❤

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

    Great explanation and the best part is your approach towards the question, it really helped me, thanks a lot bhaiya.

  • @narendramohanpathak4456
    @narendramohanpathak4456 8 หลายเดือนก่อน +4

    It seems there is an issue in the deletion function. It is only checking either the left or right child, whereas it should check both the left and right children, similar to how it's done in the heapify function.

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

    thank you for being so great with us, you have clarified the searching technique of parent, left and right node so easily.

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

    Bhaiya aap boring ko bhi interesting bana dete ho, your teaching is very good

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

    First time commenting best channel for dsa

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

    even after 6 months no had made Data Structure course like yours Babbar bhaiya.

  • @RohitRana-tz2lr
    @RohitRana-tz2lr 2 ปีที่แล้ว

    Mja hi aa gya bhaiya aap se heap topic pdke... Thanks, bhaiya for making such an amazing course

  • @avishkarpatil5871
    @avishkarpatil5871 9 หลายเดือนก่อน

    45:02 // H/W - How function - buidHeap takes O(N) why not O(Log N) as it is n/2
    Lets Dive into code , as during each Iteration the , heapify function takes O(Log N) time , so when we call n/2 each element takes O(Log N) time till it reaches 1 as O(Log N) + O(Log N) + O(Log N) ------- 1
    which boils Time complexity as O(N) for buidHeap() Function
    Hope you got it

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

    Mja a gya ......such an elaborative and simple explanation

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

    Thank you Bhaiya 🙏 aisa course dene ke liye, ab lagta hai kuch kar sakta hai aapn log.

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

    Lecture was superb dear Thanks a lot for such amazing content!

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

    in insertion short if you add provided code in last of while loop then it will give correct answer , right now if you try sir's code with insertion of - 50 then 52 then 53 then 54 then 55 then you definately get wrong answer , here is something i want to add
    if(index%2 ==0){
    if(array[index] > array[index+1]){
    swap(array[index] , array[index+1]);
    index++;
    }
    }
    if you add this at the place as told then your code will correct answer iin any case

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

    Bhaiya deletion thoda wrong lag raha hai. Let's say right child bada ho left child se to uss case mai ham leftchild index se swap kar rahe hai and index to aage nikalke ja raha hai so max heap ki property satisfy nahi karega na .
    So pahle ye check karle ki left and right mai se konsa bada hai and then swap kar le to ho jayega.
    E.g. int largeChild = arr[leftChild]>arr[rightChild] ? leftChild:rightChild
    Then only 1 condition if ye largeChild index se bada hai to swap else return
    Amazing content bhaiya. Maja aa raha hai...

  • @vanshsharma9453
    @vanshsharma9453 8 หลายเดือนก่อน +1

    Best DSA Teacher

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

    thanq thanq thanq bhaiyaa .. majja agya isme toh .. kamaal krte ho aap..

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

    World number 1 DSA course.

  • @AAnand-my1ql
    @AAnand-my1ql 2 ปีที่แล้ว +2

    Best video for understanding heaps. Thank you so much!

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

    Really great consistency hai sir aapki I'm not able to match till now even🌚

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

    Ek hi to dill he kitnaa jitoge bhaiya 👌😂😂

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

    heapify function line 88 and 91 mein correction(left

  • @balvindersingh339
    @balvindersingh339 11 หลายเดือนก่อน +4

    I think there is an error in the deletion part.
    We are first checking the left then right.
    But what if right part is maximum?
    Try making a heap this way and you'll understand:
    50 55 54 53 53
    upon deletion, we get :
    53 52 54 50: 53 becomes root and 54 comes later...

    • @ashutosh7944
      @ashutosh7944 11 หลายเดือนก่อน +1

      there is no problem in sir code it is 100% correct
      listen if there is no need to swap in left then we swap in right side
      then this means we have to forget the left subtree for further sorting because there is no need and vice versa and this continues until all conditions fulfilled and then return
      if you dry run you will notice this:)
      believe me just dry run

    • @dipjain8679
      @dipjain8679 11 หลายเดือนก่อน

      there is a problem,take example as 52 53 54 50 you will get wrong answer as:53 52 54 50@@ashutosh7944

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

      ya you are right its wrong and incomplete

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

    Attendance marked ...
    Thank you so much for this course

  • @nishchaybhokare2858
    @nishchaybhokare2858 9 วันที่ผ่านมา +1

    your videos are really helpful... Thank you.

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

    At 25:30 the deletion code may not work for other input values (like : 50,60,70,80,90,100).
    Another if condition is required to find the larger value between arr[leftIndex] and arr[rightIndex],
    for this use :
    void Delete(){
    if(size < 1){
    cout

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

    Attendence Marked Bhaiya...Up to dated m, And enjoying every lectures till now,,Thanks A Lot....

  • @thatboysus-tm
    @thatboysus-tm 3 หลายเดือนก่อน

    Corrected Code dealing all edge case for deletion in max heap:
    Hope Sir corrects it in future and add it in description !
    void deletefromHeap(){
    if(size < 1) return;
    swap(arr[1],arr[size]);
    size--;
    int index = 1;
    while(true)
    {
    int leftIndex = index*2;
    int rightIndex = index*2+1;
    if(leftIndex arr[rightIndex]) break;
    else
    {
    if(arr[leftIndex] < arr[rightIndex]) {swap(arr[rightIndex],arr[index]);index = rightIndex;}
    else {swap(arr[leftIndex],arr[index]);index=leftIndex;}
    }
    }
    else if(leftIndex > size && rightIndex arr[rightIndex]) break;
    else
    {
    swap(arr[rightIndex],arr[index]);
    index = rightIndex;
    }
    }
    else if(leftIndex size)
    {
    if(arr[index]>arr[leftIndex]) break;
    else
    {
    swap(arr[leftIndex],arr[index]);
    index = leftIndex;
    }
    }
    else break;
    }
    }

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

    28:32 there is small correction in the code that is
    if(leftIndex < size && arr[i] < arr[leftIndex] && arr[leftIndex] > arr[rightIndex]) in line 57
    The reason :
    we need to compare the left and right children before swapping that's why we added another conditional " arr[leftIndex] > arr[rightIndex]" and there is no need to add "arr[leftIndex] < arr[rightIndex]" in else if part.

  • @Ma.keITEasy
    @Ma.keITEasy ปีที่แล้ว

    You know you are beauty with brains!!

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

    Hats off to dedication level of bhaiya for us.

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

    Thanks love bhaiya😀 Placement lagne ke baad apko mere taraaf se party pakki😁

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

    Best course for DSA
    Thanku bhaiya

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

    Sab samaj gaya sir 🔥🔥🔥

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

    //// Modified and correct Code of deleion() function :
    void delroot(){
    if(size==0){
    cout

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

    00:03 Heaps in C++ and Heap Sort
    03:27 Understanding the structure and composition of a heap
    07:14 Heap property in C++
    09:27 Understanding insertion and deletion in a heap
    15:44 Understanding and implementing the Inverter function
    17:50 MS Word printing and setting pins
    22:17 Deletion in Heap
    24:20 Explanation of heap sorting and insertion/deletion in heap
    29:46 Lecture 74 discusses Heaps in C++ including Heap Sort, Insertion/Deletion in Heap, and Priority Queue STL.
    32:23 Understanding the concept of heaps in C++
    36:45 Explanation of shifting inside a heap and its significance
    38:44 Heaps in C++ and Heap Sort
    43:14 Explanation of the heap sort algorithm
    45:37 Heap Sort in C++
    50:11 Heap Sort is a sorting algorithm that utilizes a heap data structure.
    52:22 Heaps in C++
    57:23 Heaps in C++
    1:00:09 Understanding priority queues and heap sort in C++

  • @Upload2971
    @Upload2971 4 หลายเดือนก่อน

    For the deletion code mistake, being discussed in the comments:
    Simply replace the if -- else if -- check with two ifs -- and check if "i" was modified or not.
    (0-based implementation)
    while( i < vec.size()) {
    int original_index = i;
    int left = 2*i + 1;
    int right = 2*i + 2;

    // The first check is important since we might encounter an (internal) leaf node
    if( left < vec.size() && vec[left] > vec[i])
    {
    std::swap(vec[i], vec[left]);
    i = left;
    }
    if(( right < vec.size() && vec[right] > vec[i]))
    {
    std::swap(vec[i], vec[right]);
    i = right;
    }
    if(i == original_index) // Everything is stable
    return;

    }