Javascript Freecodecamp Algorithm #34: Implement Quick Sort

Поділитися
Вставка
  • Опубліковано 20 січ 2025

КОМЕНТАРІ • 57

  • @williamsouza6760
    @williamsouza6760 8 місяців тому +1

    I'm trying to understand all the operations in QuickSort. I was struggling, but with this video, everything makes sense. Thanks!

  • @ddctechinstitute6861
    @ddctechinstitute6861 3 роки тому +2

    This is best I have ever seen. Others just make Alogrithms unnecessarily complex.

  • @davidgentilli7944
    @davidgentilli7944 3 роки тому +4

    Thank you, Justin. This is the clearest explanation I've seen!

  • @pushpakchoudhary7242
    @pushpakchoudhary7242 2 роки тому +4

    This was really really helpful. I have an interview scheduled tomorrow where I may face this question and I really loved how simply you wrote. 🙏 Thanks

  • @donghwip
    @donghwip 2 роки тому +1

    I was trying to understand quick sort and this was the best explanation and simple clean code. Thank you so much! 감사합니다!!

  • @kristenkrofchik7998
    @kristenkrofchik7998 3 роки тому +1

    Perfect description! I really feel like I GET it now. Thank you!

  • @giantqtipz6577
    @giantqtipz6577 3 роки тому +4

    wow thank you for this.
    I had just started learning Quicksort through Colt Steele's algorithm course, and your video is much much much straightforward.

    • @tesfatesfaye6262
      @tesfatesfaye6262 Рік тому

      Dude, I am literally am a section away from finishing his course, most of which was pretty straight forward, except this and maybe one or two other things, literally in the same boat as you.

    • @giantqtipz6577
      @giantqtipz6577 Рік тому

      @@tesfatesfaye6262 funny youre commenting now.
      At the time I was in Marketing Analytics trying to transition into Software Engineering.
      I managed to transition last year and spent 2022 in SE. Ive built websites, web applications, desktop applications, web crawlers, automations and more all in one year in a music company.
      But I quit back in January of this year because of stress. The burn out was real. Im at a point of my life where I need work life balance
      Anyway Im back in Marketing but trying to get into Data Science. I use Python at work for analysis and automation. My work life is better. Sometimes I have days where I do nothing lol.
      I was just unlucky with the company where I was an engineer I guess. There are plenty companies with good balance as an engineer, but not where I was.
      Anyway just wanted to share that in case youre trying to break into SE.

    • @tesfatesfaye6262
      @tesfatesfaye6262 Рік тому +1

      @@giantqtipz6577 The main thing is you went out and did it, you made a choice to try and do something challenging and did it. However, nothing is worth one's well being, thank you for being an inspiration.

    • @giantqtipz6577
      @giantqtipz6577 Рік тому

      @@tesfatesfaye6262 appreciate that. I wish you the best in this tough market. It took me 5 months to land my first SE job back in 2021. It was a tough market, but I heard its even tougher now.

  • @everythingandanything2457
    @everythingandanything2457 4 роки тому +25

    But Quick Sort is an in-place sorting algorithm...if we use left Array and Right Array, what will be the space complexity....just curious

    • @liondeluxe3834
      @liondeluxe3834 4 роки тому +5

      Was wondering the same thing

    • @vnm_8945
      @vnm_8945 4 роки тому +1

      Worst scenario - space complexity: O(log(n))

    • @samwhite9516
      @samwhite9516 4 роки тому

      does anyone know of a linear space complexity solution in JS?

  • @desireeconceicao1621
    @desireeconceicao1621 4 роки тому +3

    Thanks, this was a wonderful video. Really helped me understand how quick sort works.

  • @Lashistoriasdelilith
    @Lashistoriasdelilith 2 роки тому

    I understood perfectly and your recomended video was enlightening too.

  • @paschalynukwuani6930
    @paschalynukwuani6930 2 роки тому

    You are awesome. I really enjoy watching your videos

  • @muxammad2777
    @muxammad2777 3 роки тому +1

    thank you very much i have one question, when do calling recursive function end how does the recursive function know when to stop ??

  • @harkiratsingh9071
    @harkiratsingh9071 3 роки тому

    finally i understand concept of quick sort from his video .. thanks a lot

  • @whatwhat3435
    @whatwhat3435 4 роки тому +3

    what an explanation... loved it

  • @rohinimirashe9844
    @rohinimirashe9844 2 роки тому

    What is the time complexity and space complexity of these quick sort

  • @atiktook8591
    @atiktook8591 3 роки тому

    So far this is the best explanation for me! Thank you Justin

    • @ddctechinstitute6861
      @ddctechinstitute6861 3 роки тому

      True. The best other books and videos just make things unnecessarily complex

  • @mohdtazammul4699
    @mohdtazammul4699 2 роки тому

    woahh Man !!!, I must say this implementation is far far better than others one. Easy to understand, easy to implement. Subscribed you..🫡

  • @myrelaxpoint
    @myrelaxpoint 4 роки тому +1

    Wow... Who would have thought someone could explain QUICK SORT that easily.

  • @guyowen768
    @guyowen768 4 роки тому +3

    Clear explanation thank you.

  • @RooftopKorean1992
    @RooftopKorean1992 2 роки тому

    Yo Justin, can you explain why we are putting pivot in the middle? [...quickSort(left), pivot, ...quickSort(right)]

  • @aj98767
    @aj98767 2 роки тому +1

    I think we can further improve this using javascript's filter HOF. Although it introduces another abstraction it is not that hard to understand and it minimizes the code a lot. So this is how I think you can do this: First, replace your left variable and instead assign a filter function in it like this "array.filter(item => item < pivot)", and then replace your right variable and instead assign a filter function like this "array.filter(item => item > pivot)". I think that reduces 3 lines of code at least.

    • @henryleestudio
      @henryleestudio 2 роки тому +1

      It doesn't work with duplicate numbers

    • @alero9505
      @alero9505 5 місяців тому

      using that approach is not optimal, bc you are doing 2 loops using those "filter" method in the array

  •  3 роки тому +1

    Quick sort is in-place algorithm. This is more similar to merge sort.

  • @nathanchungh
    @nathanchungh 3 роки тому

    This video was amazing. thank you

  • @artemshcherbyna6707
    @artemshcherbyna6707 3 місяці тому

    This solution has a leak memory problem. It doesn't work with 1*10^4 array length

  • @vnm_8945
    @vnm_8945 4 роки тому

    nice explanation, but I have a question: in the syntax of slice method, the end argument is not included, is it necessary to write slice(0, array.length - 1) instead of slice(0, array.length)? Thanks.

    • @rakotonirinaolvanotjeancla1990
      @rakotonirinaolvanotjeancla1990 3 роки тому

      Because he doesn't want to include pivot number, but in the end he included it by returning [left, pivot, right]

  • @Cyber99221
    @Cyber99221 3 роки тому

    Again, great video!

  • @RehmanKhan-qi4up
    @RehmanKhan-qi4up 3 роки тому

    u r my saviour

  • @linlinli2440
    @linlinli2440 3 роки тому

    i like your method but i dont know about the space complexity.

    • @dcastro97
      @dcastro97 3 роки тому

      I was looking for this comment.. they way he did that is absolutely simple but I think he's using more memory because he's creating two more arrays, right?

    • @amitkumar-xu3ie
      @amitkumar-xu3ie 2 роки тому +1

      @@dcastro97 yes and quick sort is supposed to be in-place and should use space in O(1) unlike merge sort which uses O(n) but here quick sort is using O(n) memory like merge sort.

  • @iba001
    @iba001 4 роки тому

    thanks for the "quick" explanation ;)

  • @shubhamjoshi8733
    @shubhamjoshi8733 4 роки тому

    Thanks ✌, Great job 👏👏

  • @chandanpatra3850
    @chandanpatra3850 4 роки тому

    just wowo sir you are great.

  • @snooow2879
    @snooow2879 4 роки тому

    this helps me! thank you!

  • @mamthavenkatesh9990
    @mamthavenkatesh9990 Рік тому

    This implementation does not sort this array [-1, -6, 5, 9, 2, 10, 67]

  • @bernardus3289
    @bernardus3289 2 роки тому

    wow at first I thought that recursion wasnt needed here bc ur just spreading the 2 arrays. Then I realized the recursion is sorting each array over and over. My mind is so slow

  • @jamezjaz
    @jamezjaz 3 роки тому

    Subscribed!

  • @agunbiadebasit2837
    @agunbiadebasit2837 3 роки тому

    Man the way you teach algo needs to be studied as a course

  • @RehmanKhan-qi4up
    @RehmanKhan-qi4up 3 роки тому

    u r the guy kim

  • @chickenboysdonath
    @chickenboysdonath 4 роки тому

    thanks

  • @aaronargottelopez3488
    @aaronargottelopez3488 3 роки тому

    Thanks