Quick Sort Algorithm Explained (Full Code Included) - Python Algorithm Series for Beginners

  Рет қаралды 172,646

Derrick Sherrill

Derrick Sherrill

Күн бұрын

This is a part of a full algorithm series - Check it out here:
• Bubble Sort Algorithm ...
Kite helps fund the channel, thanks for checking them out and supporting me --
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. www.kite.com/get-kite/?...
#Python #QuickSort #Algorithm
In this one we're covering the quick sort algorithm! One of the favorite sorting algorithms due to its speed in an average case.
The Quick Sort algorithm takes an item from the unsorted list and uses it as the 'pivot' or the item to compare the remainder of the items in the list. We do comparisons placing the items in lists according to if they are larger or smaller than the pivot value.
We repeat this process creating smaller and smaller lists until we have list values of one which have been sorted.
Join The Socials -- Picking Shoutouts Across KZbin, Insta, FB, and Twitter!
FB - / codewithderrick
Insta - / codewithderrick
Twitter - / codewithderrick
LinkedIn - / derricksherrill
GitHub - github.com/Derrick-Sherrill
Thanks so much for the continued support of the channel! You guys are awesome and I'm very thankful to be at this point. 5,500+ subscribers at the time of writing. Thank you all so much!
*****************************************************************
Full code from the video:
def quick_sort(sequence):
length = len(sequence)
if length #less than= 1:
return sequence
else:
pivot = sequence.pop()
items_greater = []
items_lower = []
for item in sequence:
if item #greater than pivot:
items_greater.append(item)
else:
items_lower.append(item)
return quick_sort(items_lower) + [pivot] + quick_sort(items_greater)
print(quick_sort([5,6,7,8,9,8,7,6,5,6,7,8,9,0]))
#KZbin Doesn't allow angled brackets - Sorry about that!
github.com/Derrick-Sherrill/P...
Packages (& Versions) used in this video:
Python 3.7
Atom Text Editor
*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:
github.com/Derrick-Sherrill/D...
Check out my website:
www.derricksherrill.com/
If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!
--- Channel FAQ --
What text editor do you use?
Atom - atom.io/
What Equipment do you use to film videos?
www.amazon.com/shop/derricksh...
What editing software do you use?
Adobe CC - www.adobe.com/creativecloud.html
Premiere Pro for video editing
Photoshop for images
After Effects for animations
Do I have any courses available?
Yes & always working on more!
www.udemy.com/user/derrick-sh...
Where do I get my music?
I get all my music from the copyright free KZbin audio library
kzbin.info...
Let me know if there's anything else you want answered!
-------------------------
Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!

Пікірлер: 391
@NEMOBANDZBEATS
@NEMOBANDZBEATS 2 жыл бұрын
This is the best explanation I have seen so far. It’s like other people try to explain things in the hardest way possible so you could think they’re more smart lol
@ugurdev
@ugurdev 3 жыл бұрын
Hey man, you are one of the most underrated channels on youtube for Python. It is sad to see you haven't uploaded in a while, but I hope everything is going well for you. Thank you for all you have done.
@tai-shanlin615
@tai-shanlin615 4 жыл бұрын
this is the cleanest implementation of quicksort that I have seen. period. So easy to follow! Subscribed
@UnknownSend3r
@UnknownSend3r 3 жыл бұрын
100% it was clear and concise.
@riszard999
@riszard999 3 жыл бұрын
it's slower and has bigger memory complexity :)
@tursunalikholdorov1853
@tursunalikholdorov1853 3 жыл бұрын
@@riszard999 Do you know more efficient implementation?
@UnknownSend3r
@UnknownSend3r 3 жыл бұрын
@Leland Jon ofcourse we care that you hacked her account in 15 mins, Il be sure to use it once I've replied to that Nigerian prince that's been messaging me recently.
@waseemq1522
@waseemq1522 3 жыл бұрын
FRRR
@ctormin
@ctormin 3 жыл бұрын
I wish every video on the internet was like this. You made my day, for real.
@fuleswaripal9536
@fuleswaripal9536 3 жыл бұрын
Why is this dude so underrated . I was searching for tutorials of sorting algorithms I didn't find a single video which explained well and mostly all the sorting videos were about bubble sort . Now after 2 days his video come to my recommendation.And yeah bro keep up the good work I can't even explain how much these sorting tutorials helped me keep it up . You will surely get what you deserve once👍👍😁
@nikomiller6168
@nikomiller6168 3 жыл бұрын
Great tutorial! However, quicksort is an in-place algorithm. This implementation is not in-place since it creates new lists rather than modifying the original. The in-place version is naturally a bit trickier, which is why most people seem to get your version better. Nevertheless, this video does a great job in explaining the intuition behind the algorithm.
@icewreck
@icewreck 3 жыл бұрын
Quick sort is generally in-place, and your implementation, while simple to understand, is isn't which means it would have a disastrous memory footprint for larger input sets.
@user-ky2vl2wm3j
@user-ky2vl2wm3j 2 жыл бұрын
With all that animation and description, it was great. So clean. I'm a beginner at programming and yet all this made complete sense. Thanks, man. Subscribed.
@user-ze7sj4qy6q
@user-ze7sj4qy6q 3 жыл бұрын
just found this channel rn and this dude is so easy to understand and chill (but not boring) untapped resource of knowledge right here
@glorysonhorace3265
@glorysonhorace3265 2 жыл бұрын
I'd definitely recommend this channel to everyone who wants to learn DSA in a very clear and easy-to-understand way. Thanks Derick Sherrill for this tutorial. Keep posting more and more videos
@chesslearn8103
@chesslearn8103 4 жыл бұрын
I have finally found a clear, well explain and simple answer to my questions. Ty very much.
@shreehari2589
@shreehari2589 3 жыл бұрын
This gotta be the awesomest explanation about quick sort, great job Derrick keep up the good work, i hope to see more data structures and algorithms tutorials from you!!!
@UnrecycleRubdish
@UnrecycleRubdish 4 жыл бұрын
This was incredible. Thank you for explaining these algorithms in simple terms for beginners to understand. Your explanations are clear and your code clean. Cannot be thankful enough.
@Sixthfred
@Sixthfred 4 жыл бұрын
Although it isn't in-place, your tutorial was very simple to understand and should definitely be how Quicksort ought to be taught!
@anshimagarg9661
@anshimagarg9661 3 жыл бұрын
Oh my god !! The best video of quick sort ! This is the first time I visited your channel and I'm totally recommending this to all my friends !!! thanks s lot ❤️❤️
@benjaminbennington213
@benjaminbennington213 3 жыл бұрын
Wow that was amazingly simple. I learned this a while ago in college, but my teacher made it a 3 week process that was beyond confusing. That was so clean and simple. Great job. I immediately subscribed.
@pratikzajam799
@pratikzajam799 4 жыл бұрын
man ur amazing, understood first time quick sort in my life
@abhinabamajumder4818
@abhinabamajumder4818 4 жыл бұрын
Thank you so much specially for simplifying it to such an extent. Artistic elegance!
@0xd4n10
@0xd4n10 4 жыл бұрын
Amazing explination! Most of the other tutorials are so hard to follow. Subscribed!
@shangliu6687
@shangliu6687 4 жыл бұрын
The best video for quick sort explanation!!! Clean and clear! theoretical and practical!
@dikshyantauprety4020
@dikshyantauprety4020 2 жыл бұрын
The simplicity of this is divine..... Thank you so much
@ayman6237
@ayman6237 4 жыл бұрын
This is the best, cleanest, efficient and the most beginner friendly quick sort algorithm i've stumbled upon. Thanks my man!
@fazilrahmanz9797
@fazilrahmanz9797 4 ай бұрын
I was like keep on looking into many youtube videos to find a perfect video for quick sort then landed over here and got the most easiest and understandable way to code it in python for the quick sort !!
@samer820
@samer820 2 жыл бұрын
I have watched multiple quicksort videos and so far this is the best and the cleanest explanation I have seen so far 👍
@abhishekbhardwaj7214
@abhishekbhardwaj7214 4 жыл бұрын
Thanks for making it a piece of cake man, cheers.
@user-ng4bc3cv6g
@user-ng4bc3cv6g 3 жыл бұрын
Thank you, I understood the algorithm in the first 2 minutes of the video.
@girishkakumanu4117
@girishkakumanu4117 Жыл бұрын
FANTASTIC TUTORIAL! I always thought quick sort was the hardest, but your video helped me learn it thoroughly. Tysm!
@jonathanphillips5915
@jonathanphillips5915 3 жыл бұрын
This was really helpful man! You explain it so clearly and calmly, thanks a bunch man!
@armberg8935
@armberg8935 4 жыл бұрын
this channel is amazing, had trouble understanding my lecturer but this was super clear!
@ezekieljoseph1668
@ezekieljoseph1668 6 ай бұрын
Thanks, you have no idea how much this helps.
@webknowledge9989
@webknowledge9989 2 жыл бұрын
this is the BEST explanation of quicksort, EVER.
@ireneashamoses4209
@ireneashamoses4209 4 жыл бұрын
Amazing!! Thank you so much!! I was looking for ages for a simple explanation and logic 😆💗💗👍👍
@msh104utube
@msh104utube 3 жыл бұрын
Nothing beats the smell of clean code in the morning. Great job, very clean code.
@Knut_Eisbaer
@Knut_Eisbaer Жыл бұрын
That was an incredible explanation, man. That's pure elegance.
@arielm7248
@arielm7248 3 жыл бұрын
Amazing explanation!!!!!!!! Much better than what my TA's and Prof did in a whole week.. you did it in 6 minutes!!!! Thank you~~
@Nick-gs4em
@Nick-gs4em 2 жыл бұрын
Bro keep doing what you're doing I spent like an hour trying to understand quicksort, and the code to implement it, and I got it after 5 minutes of your video!
@robertue1
@robertue1 2 жыл бұрын
Great, really simple and easy to follow explanation, thanks Derrick.
@sud0gh0st
@sud0gh0st 2 жыл бұрын
You explained it perfectly in 6 minutes can't argue that this is content with value got my sub
@PeizhiYan
@PeizhiYan 9 ай бұрын
Absolute amazing! Your tutorial is the best and most understandable I have ever watched!
@richcs8287
@richcs8287 2 жыл бұрын
Hi Derrick, Thanks for wonderful and simple explanation of the quick sort algorithms. Never understood the quick sort much better.
@edwinjonah
@edwinjonah 3 жыл бұрын
Wow, it looked so complicated and you just made it simple! Amazing, thanks a lot.
@wissammoussa7540
@wissammoussa7540 3 жыл бұрын
oh my god man thank you!!! I wasted my afternoon watching quicksort animations and I finally understand it
@engdoretto
@engdoretto Жыл бұрын
The best explanation I found on the internet… thanks a lot!
@nappdaddy2000
@nappdaddy2000 4 жыл бұрын
just finished mosh's python course...was interested in algorithms for sorting and graphing(searching)... Great video, well explained, thanks mate!
@tingtingcheng6386
@tingtingcheng6386 9 ай бұрын
Amazing, after watching so many videos... I finally got it! so underrated tutorial
@miguelmarques6233
@miguelmarques6233 2 жыл бұрын
Such a good and simple way of explaining quick sort! Thank you for sharing!!
@rob_dyy
@rob_dyy 3 жыл бұрын
This is one of the cleaner implementation of all the quicksort I've seen
@HamzaKhan-zj6dn
@HamzaKhan-zj6dn 4 ай бұрын
first time was able to understand this algo....loved it...
@gabrielkondo5246
@gabrielkondo5246 Ай бұрын
Bro, this is the best explanation and small and eficient code i've ever seen so far
@nehalzaman1159
@nehalzaman1159 Жыл бұрын
Thanks sir! I have seen various implementations of quick sort that literally made no sense to me, until I saw your explanation. That is really an awesome implementation. If I say thanks 100 times, that would still not enough. Keep up the good work, sir!
@kamilosok4454
@kamilosok4454 3 жыл бұрын
You wrote this algorithm more clearly than anyone else I've seen
@shrirajshakunt7203
@shrirajshakunt7203 2 жыл бұрын
Where were you, Derrick...you saved my life. best of best programming video so far.
@shahzan525
@shahzan525 4 жыл бұрын
Awesome man awesome ...... I never see that easiest explanation on KZbin...... But damm absolutely great.....
@turjo119
@turjo119 3 жыл бұрын
My God I've been searching for hours for an easy coding solution to follow. Your vid literally saved me! Thank you so much
@ShahidiDewitness
@ShahidiDewitness 3 жыл бұрын
Amazing content. I'm reading Grokking Algorithms books and this greatly supplements my knowledge being first time I'm learning these advanced algorithms. Much appreciated and blessings 👊🏿
@nokibulislam9423
@nokibulislam9423 4 жыл бұрын
this is the most underrated channel i have ever seen .Keep up the good work man
@norbertoignaciojr3365
@norbertoignaciojr3365 3 жыл бұрын
Subscribed!!! Very clean and concise explanation!! Im just starting out with algorithms yet you explained it very well :D keep going buddy!
@RobsondaMota
@RobsondaMota Жыл бұрын
Thank you for your concise and easy to understand implementation Derrick. Very good videos. Thanks!
@lokeshnaidu1935
@lokeshnaidu1935 3 жыл бұрын
Ohhhhhh your code logic simplicity is really awesome derrick
@arunnp7348
@arunnp7348 2 жыл бұрын
Excellent explanation...I went through multiple videos about quick sorting & Hands down , this one is the best !!
@hitechdivyanshu6329
@hitechdivyanshu6329 3 жыл бұрын
great man this is one of the easiest quick sort algo i've ever seen....liked and subscribed
@user-hp2kj5rf5d
@user-hp2kj5rf5d 11 ай бұрын
THANK YOU SO MUCH! This was beyond helpful.
@roubarizkallah2172
@roubarizkallah2172 3 жыл бұрын
Strongly recommend this video for beginners. Cute guy and great teacher, what else would u ask for XD. More seriously now, short video with good editing going straight to the point and explaining this concept in a simple way. Thank you man, keep it up.
@SuperMixGamer
@SuperMixGamer Жыл бұрын
thank you very much, this was the best implementation i could find and the easier to understand
@stillbald5827
@stillbald5827 3 жыл бұрын
Thank you! This was super clear and helpful. Would love to see a follow up where you talk about different ways to optimize this.
@dharineeshkarthikeyan1868
@dharineeshkarthikeyan1868 4 жыл бұрын
Thanks so much ..really helped me understand quick sort much better and in such a easy way
@JustMalla
@JustMalla 4 жыл бұрын
Thanks for the video! Simple and on point ❤️
@mohitshetty8535
@mohitshetty8535 2 жыл бұрын
You are making coding easier for me. Thank you.
@reversekick4832
@reversekick4832 3 жыл бұрын
Hey @Derrick Sherrill, That was a very straightforward approach. Thanks, really appreciate it!!!!
@kavizz_lifestyle
@kavizz_lifestyle 2 жыл бұрын
The best. Dropping a like. Subscribed. Suggested your channel to my friends. Keep doing more videos like this !
@hsoley
@hsoley 2 жыл бұрын
Amazing Derrick, learned alot! Thank you from freezing NYC
@alwayssporty8102
@alwayssporty8102 3 жыл бұрын
best quicksort video on this planet thanks bro
@nitroflap
@nitroflap 3 жыл бұрын
Thanks a lot. I've been searching for something like this. And I've found this video. It helped me create algorithm from scratch and understand it. Thank uuuu!
@jesuisravi
@jesuisravi 2 жыл бұрын
I appreciate that you take pains to make the coding easy to read. Many coding videos are essentially useless because the presenter doesn't magnify the code.
@aleksanderwieland6668
@aleksanderwieland6668 Жыл бұрын
Great explanation, simply the best! Thank you!
@shiv4667
@shiv4667 3 жыл бұрын
Was thinking of making a sorting visualiser project. Now I can code this in JavaScript for sure. Thanks man!
@nvroshni1546
@nvroshni1546 3 жыл бұрын
thank you Derrick, easy and uderstandable explaination! Thanks a lot!
@ameerhbaig
@ameerhbaig 3 жыл бұрын
Awesome videos Man!! One of the Simplest explanations on the internet
@manolo6048
@manolo6048 4 жыл бұрын
I love your vidz, thumbs up, they are clear and precise.
@srijitbhattacharya6770
@srijitbhattacharya6770 Жыл бұрын
this is certainly one of your top drawer explanantions
@kobic8
@kobic8 2 жыл бұрын
as always, great explanation Derrick! thanks
@nabnita6182
@nabnita6182 3 жыл бұрын
Omg!! It is that simple. Thanks man!
@andersontiban5356
@andersontiban5356 Жыл бұрын
You explained that so clearly! Thank you
@stevehoang9
@stevehoang9 Жыл бұрын
Thank you for your explanation. It's super clear and easy to understand!
@kabirwolly4309
@kabirwolly4309 3 жыл бұрын
This is so clean! Subscribed.
@helikopter1231
@helikopter1231 2 жыл бұрын
This pythin solution was soooooo much easier to understand! Thank you!
@cesairetchoudjuen7885
@cesairetchoudjuen7885 3 жыл бұрын
My man ! Cheers for the very easy to follow video :)
@sakshiwahi2025
@sakshiwahi2025 3 жыл бұрын
WHOA 🤯🤯 HOW COULD YOU MAKE IT SO EASY TO UNDERSTAND !!!!!
@054siddarth3
@054siddarth3 3 жыл бұрын
Oh my god! this is the best and easiest solution of quicksort, thank you so much.
@ZinduZatism
@ZinduZatism 4 жыл бұрын
U R D Man, many thanks, others explain logarithm over half hour and still struggle to understand, urs short, clear and easy thank you subscribed. please make video of merge sort as well if possible. thank you
@hamzaahmad1224
@hamzaahmad1224 2 жыл бұрын
Loved this! Very helpful
@soseofficial3923
@soseofficial3923 2 жыл бұрын
if i was rich i would have donated 10,000 dollars to you for this best explanation of quick sort. Thank you Derrick sherrill. God Bless you
@JP-xe6gn
@JP-xe6gn 3 жыл бұрын
Thanks Derrick ! Very well explained !
@pritam1366
@pritam1366 3 жыл бұрын
Man this is by far the best explanation, i wasted my time on so many videos. Thanks man
@jessicar4405
@jessicar4405 4 жыл бұрын
omg it finally makes sense now, thank you so much for the simple implementation!
@halfword
@halfword 3 жыл бұрын
Jessicar idgi
@ramonmf4358
@ramonmf4358 3 жыл бұрын
Very clear explanation..Thanks a lot, bro!
@manashbehera961
@manashbehera961 Жыл бұрын
simple and clear explanation, thanks for the video
@noahhcams
@noahhcams 2 жыл бұрын
Very understandable implementation! Thanks!
@hb6340
@hb6340 7 ай бұрын
very well and easily explained. Thank you!
@bsdtux
@bsdtux 4 жыл бұрын
Agree with the comments below. I was trying to understand the implementation from "The Practice of Programming" but quickly got confused trying to reimplement their version from C to python. Watching your video breaking down the concepts I got it right away. Many thanks for this video
Learn Quick Sort in 13 minutes ⚡
13:49
Bro Code
Рет қаралды 291 М.
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 38 МЛН
2.8.1  QuickSort Algorithm
13:43
Abdul Bari
Рет қаралды 3,1 МЛН
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
The Quicksort Sorting Algorithm: Pick A Pivot, Partition, & Recurse
26:31
Back To Back SWE
Рет қаралды 162 М.
Quicksort In Python Explained (With Example And Code)
14:13
FelixTechTips
Рет қаралды 134 М.
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 156 М.
Replace Excel If Function with Python Pandas
8:05
Derrick Sherrill
Рет қаралды 129 М.
Quicksort algorithm
20:39
mycodeschool
Рет қаралды 1,8 МЛН
Quicksort Algorithm: A Step-by-Step Visualization
9:32
Quoc Dat Phung
Рет қаралды 38 М.
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 1,6 МЛН
Gizli Apple Watch Özelliği😱
0:14
Safak Novruz
Рет қаралды 2,6 МЛН
сюрприз
1:00
Capex0
Рет қаралды 1,5 МЛН
Разряженный iPhone может больше Android
0:34