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
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.
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.
@@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.
@@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.
@@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.
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.
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.
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?
@@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.
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
I'm trying to understand all the operations in QuickSort. I was struggling, but with this video, everything makes sense. Thanks!
This is best I have ever seen. Others just make Alogrithms unnecessarily complex.
Thank you, Justin. This is the clearest explanation I've seen!
Same here
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
what you going for?
I was trying to understand quick sort and this was the best explanation and simple clean code. Thank you so much! 감사합니다!!
Perfect description! I really feel like I GET it now. Thank you!
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.
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.
@@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.
@@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.
@@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.
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
Was wondering the same thing
Worst scenario - space complexity: O(log(n))
does anyone know of a linear space complexity solution in JS?
Thanks, this was a wonderful video. Really helped me understand how quick sort works.
I understood perfectly and your recomended video was enlightening too.
You are awesome. I really enjoy watching your videos
thank you very much i have one question, when do calling recursive function end how does the recursive function know when to stop ??
finally i understand concept of quick sort from his video .. thanks a lot
what an explanation... loved it
What is the time complexity and space complexity of these quick sort
So far this is the best explanation for me! Thank you Justin
True. The best other books and videos just make things unnecessarily complex
woahh Man !!!, I must say this implementation is far far better than others one. Easy to understand, easy to implement. Subscribed you..🫡
Wow... Who would have thought someone could explain QUICK SORT that easily.
Clear explanation thank you.
Yo Justin, can you explain why we are putting pivot in the middle? [...quickSort(left), pivot, ...quickSort(right)]
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.
It doesn't work with duplicate numbers
using that approach is not optimal, bc you are doing 2 loops using those "filter" method in the array
Quick sort is in-place algorithm. This is more similar to merge sort.
This video was amazing. thank you
This solution has a leak memory problem. It doesn't work with 1*10^4 array length
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.
Because he doesn't want to include pivot number, but in the end he included it by returning [left, pivot, right]
Again, great video!
u r my saviour
i like your method but i dont know about the space complexity.
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?
@@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.
thanks for the "quick" explanation ;)
Thanks ✌, Great job 👏👏
just wowo sir you are great.
this helps me! thank you!
This implementation does not sort this array [-1, -6, 5, 9, 2, 10, 67]
It does for me - check your code
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
Subscribed!
Man the way you teach algo needs to be studied as a course
u r the guy kim
thanks
Thanks