Quicksort algorithm

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ก.ค. 2013
  • See complete series on sorting algorithms here:
    • Sorting Algorithms
    In this lesson, we have explained Quick sort algorithm and implemented it in C++. Quick sort is a divide and conquer algorithm that has an average case time complexity of O(nlogn).
    For more such videos and updates, subscribe to our channel.
    You may also like us on facebook:
    / mycodeschool

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

  • @KarthikRaja-bq7pk
    @KarthikRaja-bq7pk 5 ปีที่แล้ว +1221

    Yesterday I saw all your videos on sorting. Today in interview they asked me to explain quick and bubble sort. I got selected.
    You are a good man.
    Thank you.

    • @SumitKumar-fn3gj
      @SumitKumar-fn3gj 5 ปีที่แล้ว +11

      Which Company Brother?

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

      A company duit

    • @srivatsav9
      @srivatsav9 4 ปีที่แล้ว +68

      He passed away in 2014. Very few people can do good even when they aren't around. This is one such guy.

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

      @@srivatsav9 how could you be so sure

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

      @@srivatsav9 I have also heard about it.
      But one thing I don't get is why are there uploads in the year 2016?

  • @SudhanshuKumar-lp1nr
    @SudhanshuKumar-lp1nr 3 ปีที่แล้ว +350

    7 years ago still the best explanation out there!!

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

    Man, by freaking far the best and most simple 101 explanation of QuickSort algorithm ... what can I say, I've become a fan!

    • @be-b-57-omkarshimpi4
      @be-b-57-omkarshimpi4 5 ปีที่แล้ว +3

      We are becoming a fan so give me hawa

    • @HarshPatel-iy5qe
      @HarshPatel-iy5qe 4 ปีที่แล้ว +1

      @@be-b-57-omkarshimpi4 LAME XD

    • @097_shashanksahu6
      @097_shashanksahu6 4 ปีที่แล้ว +2

      @@be-b-57-omkarshimpi4 poor joke

    • @be-b-57-omkarshimpi4
      @be-b-57-omkarshimpi4 4 ปีที่แล้ว

      Tereko puchaa kisnee 😂

    • @097_shashanksahu6
      @097_shashanksahu6 4 ปีที่แล้ว +2

      This is a public form and whatever you write is visible to all. Maybe you don't mean it for someone specific but its the way things work. Peace☺

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

    Composed voice,patient visualization,clear depiction, you are a rock star of computer science..an Indian genius

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

    Man ...I was in college 2nd year grad 4 years ago watching this on my way to college in bus... Im watching this again to change my job .. This is the best sorting series in TH-cam crystal clear ☺️☺️

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

    Thanks to your series, I've been able to implement selection-, bubble-, insertion-, merge- and now the quicksort algorithm in the Rust programming language, through your excellent and descriptive explanation of the core concept of the algorithms, as well as the in-depth technical details. I am very grateful for your videos, much thanks.

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

    Oh...Dear sir,ii'm almost your student on youtube!!! all time appreciate your videos....you have a great skill which is helpful to most of us....thanks.

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

      You are most welcome Rebecca becky :)

    • @SonuSonu-tk5pk
      @SonuSonu-tk5pk 7 ปีที่แล้ว +2

      go to ur country and study..

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

      Beleive in Jesus Christ!!
      He is the true God!!!
      Beleive in God Jesus!!Amen!!

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

      Beleive in Jesus Christ!!
      He is the true God!!!
      Beleive in God Jesus!!Amen!!

    • @rebeccakipanga478
      @rebeccakipanga478 7 ปีที่แล้ว +18

      You act as someone who never went abroad....
      Try to take a plan and travel out of India, you gonna meet nice people even your behavior gonna change!
      Globalisation means ;having an open mind and stop thinking in a traditional way!!
      We all need each other in today life!
      You should first seek upon Jesus Christ !!
      God Jesus loves you!

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

    This man passed away but his voice still helps us and he is alive in our hearts.

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

      how do u know that he is passed away man!

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

      @@bestchannel8056 www.freecodecamp.org/news/mycodeschool-youtube-channel-history/

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

      Actualy its his friend. Not him. He works in google since sometime.

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

      @@saifulhasan2532 HUMBLE FOOL IS PASSED AWAY NOT HE HE WORK IN GOOGLE NOW

  • @anusuyarangasamy
    @anusuyarangasamy 10 ปีที่แล้ว +15

    The explanations are so crisp and clear. I always wanted someone to make videos this precise. Looking forward to more such videos in your channel.

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

    Thanks mycodeschool. One of the best part of your videos is that the writing and explanation are quick unlike other video lectures which spend most of the time in writing/erasing/repeating. One of the best teaching method I have ever seen with digital aid. Keep up the good work! Thanks a lot!

  • @turing_machine544
    @turing_machine544 13 วันที่ผ่านมา

    I somehow found your video in my first year of college (2020) and today i have graduated (2024), still when i have to revise algorithms i watch your tutorials.
    I know you are no more in this world, but your contribution to community will always be remembered sir.

  • @mycodeschool
    @mycodeschool  10 ปีที่แล้ว +35

    Hi Anthony,
    We are building a queue where we are logging all the video requests. Your video request is already in this queue. We cannot promise a timeline because video creation takes time and we only have one mentor doing it right now. We are hoping to speed up by pulling in more contribution.

  • @mycodeschool
    @mycodeschool  11 ปีที่แล้ว +64

    You're most welcome :)

    • @sainthentai7763
      @sainthentai7763 4 ปีที่แล้ว

      Hello, I just watched your video, it didn't explain many things to me, but most of them are still not clear to me. And I have one question. Why Q(A, 1, 1) ? Why not Q(A, 2, 1) ? Time: 12:54

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

      @@sainthentai7763 Because pindex was 0,and end index was 1,
      so Quicksort(A,pindex+1,end)=Quicksort(A,1,1)

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

    U made indians proud sir!
    Awesome explanation

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

    Finally somebody who actually fully explains how this algorithm works and does not skip any details. Thank you so so much! 🙏🏻

  • @kaiauden4195
    @kaiauden4195 7 ปีที่แล้ว +5

    Man, huge respect to all of your tutorials. Always appreciate your hard works!!!

  • @dance2die
    @dance2die 7 ปีที่แล้ว +45

    I've learned more about Quick Sort here than 3 books I've read on it.
    Great job @mycodeschool!

    • @erikrusso9808
      @erikrusso9808 4 ปีที่แล้ว +20

      What books did you read? Twilight?

    • @SkillUpMobileGaming
      @SkillUpMobileGaming 4 ปีที่แล้ว

      Why would you read three books on Quicksort? Quicksort is not even applicable to the real world.

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

      @@SkillUpMobileGaming It is, that's why we learn it, silly.

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

      @@SkillUpMobileGaming wtf are you talking about

    • @rayaanhussain7279
      @rayaanhussain7279 4 ปีที่แล้ว +5

      @@SkillUpMobileGaming It is literally the algorithm that is implemented in most sort functions in many language libraries

  • @rishijain7171
    @rishijain7171 7 ปีที่แล้ว +38

    love u man!!!! seriously.... the world needs more teachers like u!!

    • @paragrane5676
      @paragrane5676 5 ปีที่แล้ว

      @BeautifulDrugs Lover how do u know ?

    • @nikhilraghute6560
      @nikhilraghute6560 5 ปีที่แล้ว

      @@paragrane5676 you can go through this answer, even his mother has commented there. qr.ae/TUnAzM

    • @udaykadam5455
      @udaykadam5455 5 ปีที่แล้ว

      @@paragrane5676 because he is humblefool.
      Well known personality in Indian coding community.

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

    finished first year 2 years ago but i find myself back here to brush up on some basics before a final exam. This man will forever be relevant mycodeschool keep up the good work

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

    As a Profesional Full Stack Software Developer; I always come back to mycodeschool just to listen to your voice again. Thank you master; your reward is in haven...

    • @bhuvanesharasu
      @bhuvanesharasu 4 ปีที่แล้ว

      He really did pass away in 2014 in a accident.

  • @AlexanderMcNulty92
    @AlexanderMcNulty92 7 ปีที่แล้ว +50

    *that moment when he shows the code at the end*

  • @sethigoldy
    @sethigoldy 10 ปีที่แล้ว +48

    Less than 18 hours from my exam its good to watch this video

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

      lmao yuh tell us plz

    • @spyrex3988
      @spyrex3988 4 ปีที่แล้ว

      @rocky rawlo don't fuck with me nigga

    • @varsh5192
      @varsh5192 4 ปีที่แล้ว

      @rocky rawlo On TH-cam?

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

      @rocky rawlo 😂😂

  • @indrasishbanerjee5115
    @indrasishbanerjee5115 8 ปีที่แล้ว

    This channel needs to get more recognition. Without this I wouldn't have sound knowledge on different sorting techniques. Thank you!

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

    Thank you so much for this video - this is the only one I've found that was really clear on both the concept and, more importantly, the implementation of the algorithm.
    You have real talent as an educator, and I'm sure there are many people who appreciate your tutorials - hope to see more in the future, if you have time!

  • @mycodeschool
    @mycodeschool  10 ปีที่แล้ว +18

    You're welcome Luisa :)

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

    i really love this guy, he's the very good at making something really complicate understandable

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

    Explaining the tracing of the algorithm helps sooo much especially with recursion. So helpful!

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

    Wow! I couldn't find a single video that explains quicksort better. Thank you so much for such a thorough and easy to understand tutorial!

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

    "Think about it and you will get it" - well said my friend, well said.

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

    You do great job, thank you!
    This particular way of choosing the end point as pivot has an interesting side effect to learn for beginners. If you try to sort some already sorted array like {1,2,3,...,100000}, you get the stack overflow error. It's almost obvious, because pIndex will be 99999, 99998, 99997 and so on. So after some recursions the program crashes.

  • @nipunb20
    @nipunb20 5 ปีที่แล้ว

    Been going over all your videos over the past several weeks - the content and presentation is amazing. I've learned so much and now I have much better intuition of all these algorithms.

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

    I've been trying to get quick sort down for 3 days, read tons of posts on it, this is the 4th or 5th video I've watched. This was better than any of the short ones I watched and goes in depth and actually works well. Thanks!

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

    Just wondering, do you write your own Subtitles/Closed Captions? Because they seem to be unusually spot on.

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

      Colt Wilson We get help from some volunteers.

  • @Abhi-eo6jy
    @Abhi-eo6jy 2 ปีที่แล้ว +3

    almost 9 years ago still the best explanation out there!!

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

    I have not come across a single video on quick sort which explains the working as well as the pseudo code so much clearly, thank you!

  • @ArjunPatel-hi5eq
    @ArjunPatel-hi5eq 9 ปีที่แล้ว

    I love how you really explain and show the base case in action

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

    Thank you so much for this video! I was stuck on understanding the implementation and your video helped me understand the logic we use when writing the code. Thank you!!!!

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

    Nice video .., Explaining in-detail. this is best video to understand quick sort algorithm.

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

    There can not be a better explanation for quick sort than this one, hands down!

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

    THIS MAKES SO MUCH SENSE THANK GOD. i spent a whole two hours trying to figure out things with another video that was way more confusing than this. thank you!!! you sir, have saved me from like two more hours of stress. much appreciated.

  • @venkarri8534
    @venkarri8534 10 ปีที่แล้ว +5

    Excellent tutorial. Combining code with visualization is incredibly great. Keep up the good work. Could you please post a video on building a heap data structure, with all its operations (insert, delete etc.) including heap sort ?

  • @Paul-yw4yr
    @Paul-yw4yr 10 ปีที่แล้ว +22

    Wow, great explanation! I thought I would need more time to get this. Thank you =))

  • @rutwikhiwalkar9583
    @rutwikhiwalkar9583 4 ปีที่แล้ว

    After watching like 100 different videos I finally understand this, implemented in both python and java works as expected. Good job dude!

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

    Thank you, this was incredibly helpful! Good breakdown from the basic idea to the implementation. Every other video I tried did a shoddy job of explaining what quicksort actually is - they just jumped into doing it and meaninglessly telling you what to do.

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

    sir, seriously, u r awesome. thank you so much for the playlists!

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

    Absolutely wonderful tutorial, thank you very much! I couldn't find any video that explained this as clearly as you did. Your annotations and colors are great.

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

    the only guy who has been able to make me understand quicksort this easy

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

    Simply, great buddy, I have been looking around for a simple explanation as this for a very long time now and yours is the only one that matches. keep it up bro.

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

    I Wish you were my professor of my CS department. I would top my classes after taking classes from you. So neatly explained! Loved it! 🥰😎😍

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

    indian tutorials are the best xD

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

      +wenigmehl i know lol! the depth of their knowledge and ability to explain things simply is so awesome :P

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

      +wenigmehl sarcastic

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

      oh lol that went over my head. once i get past the different accent i have actually learned a lot from them XD

    • @SonuSonu-tk5pk
      @SonuSonu-tk5pk 7 ปีที่แล้ว +1

      go to ur country...

    • @adilismail3593
      @adilismail3593 7 ปีที่แล้ว +34

      thank u brother..
      its due to the simple english followed by us

  • @kennylee6972
    @kennylee6972 6 ปีที่แล้ว

    Well done, you made it so easy to visualise what is happening on the surface as well as when you dive into the code. Not many people can pull that off

  • @laurenp2701
    @laurenp2701 9 ปีที่แล้ว

    This video really clarifies the concept of quicksort for me. Thank you for the explanation!

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

    Done thanks
    Todo take notes
    The partition function starts off with the pivot at the midpoint but ends up returning an index for the pivot AFTER all the smaller elements have been moved left of the pivot and all the larger elements right of the pivot
    15:00 logic for moving elements before the pivot

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

    Thanks mycodeschool.very nice video

  • @sandeepreddy8859
    @sandeepreddy8859 4 ปีที่แล้ว

    By far the best and most simplest explanation of quick sort algo and code.

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

    Best explanation of Quick Sort I've ever seen in my life. Thanks, man!! This video deserves way more likes

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

    I finnaly understood this sort :D .. Thank you so much

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

    "Just think about it and you should be able to get it. " towards the end hahaha

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

    I just came back to hear your voice again. People don’t understand that unlike today, the computer science in the 2010s hit a different feel.

  • @dhrubo619
    @dhrubo619 7 ปีที่แล้ว

    I was trying to look up for the quick sort codes in Java, and I stumbled upon your tutorial and by following the whole tutorial I was able to write the quick sort in Java myself. Thank you very much

  • @nikitacollier4065
    @nikitacollier4065 7 ปีที่แล้ว +5

    Good explanation! Very helpful! now i just need to implement this in assembly....not so easy lol

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

    Excellent lectures.....love ur teaching methodology....can u post the video on Shell sorting technique...?

  • @ruanlehanie5851
    @ruanlehanie5851 6 ปีที่แล้ว

    Best tutorial you'll find on quick sort, explains EVERYTHING you need to know clearly and correctly.
    Wrote my data structures and algorithms exam and I got 0 for using this method, specifically refering to the graph showing how the numbers are sorted as that is what was asked.
    This is probably due to that fact that my text book handles the quick sort algorithm differently, for instance the pivot in my text book is found through ( first element + last element ) / 2

  • @XanderWood
    @XanderWood 8 ปีที่แล้ว

    What an excellent tutorial! I didn't have a clue how quicksort worked until watching this. Thanks for the video :D

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

    Nice video as always.
    But may I know which softwares do you use for writing and recording? Also do you use a stylus for writing?

  • @johann-san
    @johann-san 9 ปีที่แล้ว +17

    I believe there is a condition that can be added to the logic to avoid unnecessary swaps. For instance, if we have the following array 7 2 1 6 4 5 3 8 where the pivot is the last and highest element 8, we would be calling the swap function unnecessarily because all the elements are less than the pivot (probably the necessary logic in this case would be just to increment the pIndex because the element is less than the pivot and is correct to be placed on the left side, hence increment the pIndex ). Adding a check to swap only if the pIndex != than i would help. Something like:
    for( i

    • @smbehindyou
      @smbehindyou 7 ปีที่แล้ว

      yes - you are absolutely correct

    • @varshar5856
      @varshar5856 6 ปีที่แล้ว

      I'm sorry, I cant get the last condition. Whats right? Is it end-1? And do you mean (Pindex!=end)?

    • @sanketughade6986
      @sanketughade6986 6 ปีที่แล้ว

      thanks brother...you saved me...i was going wrong with the pseudo code explained a lot !!...thanks a lottt !!!

    • @pvpaparaokancharapu3219
      @pvpaparaokancharapu3219 6 ปีที่แล้ว

      if(pindex != i )
      {
      swap(A[pindex],A[end])
      return pindex
      }
      else return end

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

      I think it is better to have a single unnecessary swap than to have a longer code as a longer code will require more time to process, won't it?

  • @ASCIIaday
    @ASCIIaday 5 หลายเดือนก่อน +2

    you are helping even after you left your body man hats off

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

      What happened to him :( can you name his profile?

  • @bit_FLIP
    @bit_FLIP 8 ปีที่แล้ว

    I must have watched at least 10 videos today, but this was the one that helped me to understand it the best. Thank you so much for this explanation

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

    Best tutorials out there! Better than my lectures man thank you!

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

    THIS SORTING WILL TAKE SOME TIME TO UNDERSTAND

    • @BiswasTharakath
      @BiswasTharakath 7 ปีที่แล้ว +11

      Watching it twice did the trick!

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

      It takes 20 minutes and 38 seconds to be precise ;)

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

    Thanks for saving the day, legit one of the best and simplest explanation. This is sort of the best sudo code one is looking for with complete understanding.

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

    I am watching this tutorial ....just 4 hours before my exam ( I am a Btech student and today is my practical exam on Data Structure and Algorithms).... Thank you so much sir....

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

    We really miss you sir 😢😔💔 #rip #humblefool

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

    how about if a[0] is smaller than pivot, the a[0] and a[index] (that start with zero) will change place while i++ and index++ it will swap the same index

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

      I got confused at first too. But it's just extra operation and doesn't affect the correctness of Algorithm.

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

      @@dasgoood2811 nothing happens even if u r swapping(i , pIndex) even they are in the same position only it is considered as an extra step that's it....

  • @crazystuff6760
    @crazystuff6760 4 ปีที่แล้ว

    The BEST explanation of Quick Sort Ever!!!
    Thanks for this wonderful video.

  • @qazizaahirah4168
    @qazizaahirah4168 6 ปีที่แล้ว

    Can we take a moment to appreciate your explaining skills. Great Job!

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

    wishing the legened is still alive
    rip humblefool

  • @AkshayKumar-dz5ts
    @AkshayKumar-dz5ts 7 ปีที่แล้ว +59

    //QUICKSORT
    #include
    #include
    void QuickSort(int A[],int start,int end);
    int Partition(int A[],int start,int end);
    int main()
    {
    int A[50],n,i;
    printf("Enter the number of elements: ");
    scanf("%d",&n);
    printf("
    Enter the elements: ");
    for(i=0;i

    • @sagardafle
      @sagardafle 7 ปีที่แล้ว

      Thanks man !

    • @Lollipop69420
      @Lollipop69420 6 ปีที่แล้ว

      thnx bro and btw why dont u keep c programme for all the sorting explanation as some of them dont no c++ and it ll be useful to everyone too pls take it as a request

    • @vivektodmal1
      @vivektodmal1 6 ปีที่แล้ว

      Why u need 2 temp variables you can use the same one for both the purposes in partition function

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

      Not all heroes wear capes.

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

      Program takes inputs but does not sort :(

  • @aashishgoyal1436
    @aashishgoyal1436 5 ปีที่แล้ว

    This is the best and easiest partition function i ve seen in quick sort implementation. simply too good

  • @Rajeshkumar-rj5my
    @Rajeshkumar-rj5my 6 ปีที่แล้ว

    You have done a fantastic Job! my friend. Your tutorial is so good and a complete one. I have gone through so many articles, but nothing was like this one. Explanations were crystal clear and precise as well, straight to the point, really feels good when we go through your tutorial video playlist. Well done!

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

    Very cool! The best video explaining Qucik Sort.

  • @HeyltsKenzi
    @HeyltsKenzi 5 ปีที่แล้ว +7

    Im going to win a medal at IOI 2020 in your memory Lord Harsh.R.I.P

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

      The guy explaining the video is not Harsha but it's Animesh and he's still alive.

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

    Hi Soumyajit,
    In randomized quick sort, instead of choosing pivot as last index, choose any random index (using a library function to generate random number) and first swap the number at this random index with element at last index. Rest remains the same. Try and let me know if you are not able to do it on your own.

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

    Best digital explanation of quick sort. Your videos are very rich and make use of technology amazingly to make sure that viewers understand the algorithm perfectly. Thanks a lot for creating and sharing these videos.

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

    Really great tutorial.
    I have one question, why do we need the last swap(..) method before the return statement?. If we can run the loop till the pivot element, then the pivot element will automatically come to its position after the swap. Please let me know if I am wrong.

  • @MrStarTraveler
    @MrStarTraveler 7 ปีที่แล้ว +11

    Very nice and descriptive video keep up the good work.
    But this case I have some criticism I feel is necessary since I implemented the algorithm and it doesn't work. The code presented in this video is for demonstration purposes only. The code as presented in the video works in the given case only and probably in some others but not in the general case.
    I just tried it and it doesn't work. The problem is in the partition function. For example: suppose under index 0 there is number less than four then there would be swapping of index 0 with itself since both 'i' and 'pIndex' are 0 at this point. And that swapping of the elements with themselves will continue until a bigger number is met, since both i and pIndex are incremented synchronously. The main problem however is that the algorithm can only "push" rightwards only one number. Suppose for example that at index 1 there was number 8 the first swap would change the positions of 7 and 8 and 8 would remain at index 0... And that would continue as long as the algorithm is busy pushing 7 rightwards, any other element bigger than 4 would remain in its previous place relative to the other elements. A number of passes is needed to push all numbers bigger than 4 right of the pivot.
    P.S. I only mean this as a constructive criticism, sorry If my comment sounds rude or something.
    There is a complete and working implementation of the algorithm: (look at the first answer not the question)codereview.stackexchange.com/questions/77782/quick-sort-implementation

    • @ravipapisetti1
      @ravipapisetti1 6 ปีที่แล้ว

      I agree, with your analysis.

    • @syedsouban9870
      @syedsouban9870 6 ปีที่แล้ว

      I implemented the algorithm in C and it does seem to work correctly:
      Have a look at my code in C (for a better version of code gist.github.com/syedsouban/230ad57f79b81a90812f9ba4d275d8da )
      #include
      void swap(int* x,int* y)
      {
      int t;
      t=*x;
      *x=*y;
      *y=t;
      }
      int partition(int* a,int start,int end)
      {
      int pivot=a[end];
      int pIndex=start,i,t;
      for(i=start;i

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

      MrStarTraveler, you say, " Suppose for example that at index 1 there was number 8 the first swap would change the positions of 7 and 8 and 8 would remain at index 0". That is not possible since the partition index would be advanced. The whole point is to push *only* elements less than the pivot to left and then *protect* those smaller values by advancing the pivot index, cannot see how this can be broken. cheers

    • @kaipulla77
      @kaipulla77 5 ปีที่แล้ว

      Can you give me an array input for which this doesn't work, please? I tried with duplicates and it works. Just curious.

    • @atulmalakar
      @atulmalakar 5 ปีที่แล้ว

      @@kaipulla77 5 4 3 2 1

  • @mycodeschool
    @mycodeschool  10 ปีที่แล้ว

    Not yet Ozgur ! Adding more in data structures series right now. We are prioritizing based on requests. we'll get back to this one after few more videos in data structures series.

  • @nothingpersonal21
    @nothingpersonal21 7 ปีที่แล้ว

    Man I've watched this video (and the mergesort video from this channel) before every exam, technical interview, etc for the last four years through university and whilst applying for jobs. Really excellent presentation. Thanks so much.

    • @holystone3736
      @holystone3736 7 ปีที่แล้ว

      Guys this alghoritm is a mess

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

    Did you consider negative scenario where all the elements on the left of the pivot are less than the pivot in the decreasing order ?

    • @KARTHIKPANCH97
      @KARTHIKPANCH97 4 ปีที่แล้ว

      it doesn not matter . we just want that elemnts on left of the pivot are less than the elements on its right . WE DONT CARE ABOUT THE ORDER OF ELEMENTS. THATS WHAT WE DO IN FURTHER CALLS OF QUICKSORT AND PARTITION METHODS. Finally the array gets sorted.
      This may get reflected while calculating the time complexity

  • @alizafar4399
    @alizafar4399 7 ปีที่แล้ว +4

    what does "O" and "n" in "O(nlogn) " refers to?

    • @Ramgautam12345
      @Ramgautam12345 7 ปีที่แล้ว +4

      Ali Zafar it is known as the big Oh notation, to calculate the complexity and efficiency of the program. read about it.

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

      O refers to the worst-case scenario, and n would be just a specific variable, depending on what action you're performing.
      For example, traversing an array would be O(n). n in this case would be the number of items in the array. O(n) indicates the amount of time, basically how many steps, it would take in the worst-case to traverse through that array. O(n) means that it would take n steps to traverse the array. So in this case the scalability of the method is linear. if you have 6 items in the array it would take 6 steps, if you have 12 items it would take 12 steps.
      In the case of O(nlogn), if you have 6 items in the list it would take 6*log(6) steps to implement that method. Specific numbers are not necessary for big O notation, what matters is the shape of the curve, so nlog(n) would have a logarithmic looking curve. What you're interested in is how much your function would scale depending on the input.

  • @poompataipuntidpong3700
    @poompataipuntidpong3700 9 ปีที่แล้ว

    This is really great!! I just learn programming and your video get me to understand the concept , and then I can figure the function out myself!! This is a great way of learning. Your video really deserves more views!!

  • @racastilho
    @racastilho 6 ปีที่แล้ว

    Super clear, best instructor ever! Thank you, sir!

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

    when you are doing swap(A[i],A[partitionIndex]); does the swapping happen since you are just passing variables and not the memory locations. so swapping will happen in the swa function and when you come out the original status of both the variables is returned!

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

      Manikanta Raju Good catch.. the swap function can have a signature like void swap(int &a, int &b); Now , here we are taking a and b as reference variables. Reference variable concept is available in C++ (not in C). Its different from pointer. Now, here instead of local variables, actual arguments will be swapped. BTW, in the pseudo-code, the intent was just to say that, we should swap. In Pseudo-code, we ignore compilation and other errors.

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

      mycodeschool Thanks for the reply! yeah, so its reference variable in c++. I am new to c++ , thanks for the info! By the way you are simply awesome man, making algos look simple and straight! Also can you please do a video on converting a prefix string to infix string, not computing the string, but want the infix string from prefix!

  • @anuragghosh9710
    @anuragghosh9710 7 ปีที่แล้ว +5

    sir could you provide the code link?

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

      //QUICKSORT
      #include
      #include
      void QuickSort(int A[],int start,int end);
      int Partition(int A[],int start,int end);
      int main()
      {
      int A[50],n,i;
      printf("Enter the number of elements: ");
      scanf("%d",&n);
      printf("
      Enter the elements: ");
      for(i=0;i

    • @anuragghosh9710
      @anuragghosh9710 7 ปีที่แล้ว

      thank u Muhammad Zain Zaheer

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

    best quicksort explanation I've seen. thank you

  • @vigneshk8139
    @vigneshk8139 4 ปีที่แล้ว

    I'm watching this in Feb 2020. The best explanation on quick sort algorithm.

  • @saintnoahl
    @saintnoahl 7 ปีที่แล้ว +33

    how come there are 71 unlike for this helpful video...

    • @neoanderson55
      @neoanderson55 7 ปีที่แล้ว +12

      One guess would be the accent.

    • @walidashik
      @walidashik 7 ปีที่แล้ว +15

      Now It's 79...they rotated their Display 180* and thought the unlike button is the like button :)

    • @letsrock7354
      @letsrock7354 7 ปีที่แล้ว

      may be some beginners didn't get that

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

      I used not to like the accent either, but that's okay for me now. BTW, his accent is not that strong. His clear explanantion makes great complement to his accent.

    • @standardgu3773
      @standardgu3773 5 ปีที่แล้ว

      🐰

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

    Is there any link to learn Heap sort which is explained by you ?

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

      SAINATH D'LEH Not yet,, we need to create one.

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

      mycodeschool yeah, bro make some heap sort video ASAP. thanks again.

    • @akhilsuresh2560
      @akhilsuresh2560 8 ปีที่แล้ว

      +mycodeschool IT will be very helpful ..btw gr8 work!!!

    • @ZuestTV
      @ZuestTV 8 ปีที่แล้ว

      +mycodeschool no heap yet ):

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

      +Hiimgosu My name is Animesh and I am the one who you listen to in most of these videos. Harsha who was my co-founder passed away in an unfortunate accident. But Harsha was mostly into other aspects of MyCodeSchool. I am the one who created (and still wish to create more) videos. The only problem is that I was doing mycodeschool full time earlier, but now I have taken a job and it's getting difficult to find time. But I want to get back. Hopefully, I will upload some videos soon. :)

  • @mgeasley
    @mgeasley 4 ปีที่แล้ว

    omg...finally..... the best quick sort explanation on the internet. THANK YOU

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

    i am lil puzzled your voice sounds like you are a engineering student but you knowledge matches to that of a professional software engineer....what is it in real?

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

      Before founding MyCodeSchool, I have worked in the industry for about 4 years. blog.mycodeschool.com/2013/12/the-story-of-mycodeschool.html-AnimeshCo-fonder, MyCodeSchool.

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

      Cool