Skip to main content

Two Versions of Quicksort with Python

I've been taking the Data Structures & Algorithms in Python class on Udacity.com. Lately, I've been working on implementing an in-place Quicksort two different ways. 

The first way follows the way they explained it in the class video. This version involves moving the pivot after each comparison:

The second way is based on a visualization they linked to from the lecture and this tutorial. It moves the pivot after all comparisons for each partition have been made, eliminates the need for the "j" variable that I have in the first version, and is a few lines shorter than the first version, but it is harder for me understand intrinsically:

Comments

Popular posts from this blog

Trip to Europe 2024

Steven and I got to go to Europe for two weeks. Our main stops were Amsterdam, Brussels, and London. The links in this post take you to videos that go along with the pictures. Amsterdam, Netherlands Flying to Amsterdam from Salt Lake City was over 9 hours and 5,000 miles. Phew. We took trains to get from Schipol Airport to our hotel. It took us a little while to figure out exactly how to get where we were going in our jet-lagged state, but after tapping in and tapping out a few times getting around anywhere in Amsterdam was so easy! Bikes - We loved seeing all the bikes. The Centraal Station bike parking lot was especially amazing with just how many bikes were there. Canal Tour - One of our first activities in Amsterdam was a canal tour. Definitely recommend! It was nice getting an overview of the city and its history. Bike tour - Our favorite part of the whole trip! We zipped along the fields around Amsterdam on electric bikes, saw windmills and electric pumps, and stopped at a fa...

Delicious Crepes

  Delicious Crepes 2 Tbs melted butter 2 eggs 1 cup flour Mix. Then add slowly: 1/2 cup milk 1/2 cup water 1/4 tsp salt

Fidget ball made from pony beads and keychain rings