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

Build the life you want to live. The simple things matter.

"Build the life you want to live" is a phrase that changed my life.  I learned it while stuck in a soul-sucking accounting job. I was feeling disillusioned with my new career. I wanted to help people directly, not make rich corporations even richer.  I made a pivot. I learned to code Android apps and uploaded a handful of them to the Google Play Store.  Coding didn't stick as a new career path for me, but of all the things I've made in the past decade, those little apps still make me so proud and happy.  I finally felt like I was helping people. I received a lot of nice feedback from people all over the world. One person even told me they used my little Change Calculator to help their kid get a job. I made that app 8 years ago, and I love to see people are still using it. I'm learning that "building the life I want to live"  doesn't mean I have to wait for some grand moment when everything finally comes together. Even the small stuff I'm building...

New Etsy item! Cute Panda Earrings by Amanda Roos

  Check them out in my Etsy shop: https://amandaroosart.etsy.com

Impeach and remove Trump. No more endless war.

 The Trump administration attacked Iran today. This is not ok. Protest tomorrow, Sunday, June 22, 2025. Anywhere. Noon. Make a sign. Impeach and remove Trump now.  Call your senators and representatives. 5calls.org makes it easy. Send physical mail. Don't let up.  War is expensive.  Not just money.  HUMAN LIVES. The sign I painted: