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

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


Full Code From This Example:

YouTube Description:

This is a part of a full algorithm series - Check it out here: https://www.youtube.com/watch?v=g_xesqdQqvA&list=PLc_Ps3DdrcTsizjAG5uMhpoDfhDmxpOzv #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 YouTube, Insta, FB, and Twitter! FB - https://www.facebook.com/CodeWithDerrick/ Insta - https://www.instagram.com/codewithderrick/ Twitter - https://twitter.com/codewithderrick LinkedIn - https://www.linkedin.com/in/derricksherrill/ GitHub - https://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])) #Youtube Doesn't allow angled brackets - Sorry about that! https://github.com/Derrick-Sherrill/Python-Algorithms-YouTube-Series/blob/master/4-Quick_Sort.py 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: https://github.com/Derrick-Sherrill/DerrickSherrill.com Check out my website: https://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!! Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!

Enjoy this content? Consider Subbing to the Youtube channel

Derrick Sherrill

By: Derrick Sherrill

Thanks for visiting my page! I'm working hard to make the best content I can for you. I love watching people learn and teaching others. Happy Coding!

Become a Patreon!