Screen shot 2013-12-18 at 3.49.51 PM

Implementing quicksort in C using TDD Part 2

Part 1

On GitHub

Download example files

In the previous article, we established our goal of implementing a word sorting algorithm by writing a test.

This test fails, because we have not actually alphabetized our words. But the red and green test results give us a reward mechanism that lets us measure our success.

A string in C is an array of characters. These characters have integer values which, fortunately for this task, can be sorted using number sorting algorithms.

My favorite is quicksort. You can watch a very clear explanation of this algorithm on one of my favorite Youtube channels – Computerphile.

Continue reading

quicksortfade

Implementing quicksort in C using TDD Part 1

Let’s examine a classic computer science question – how to alphabetically sort words.

In the first part, we’ll examine the problem and set up a test-driven-development template.

In part 2 we’ll examine the quicksort algorithm, and implement it to get our test to pass.

Heres our list of words (or ‘strings’ in C speak). They’re the names of some of my friend’s cats.

We’ll be using this list throughout the tutorial.

  1. Bryaxis
  2. Batman
  3. Sadie
  4. Milo
  5. Lou

Continue reading

Reworking Digital Synthesizer Source Code into a 3D Processing sketch Part 1 of 3

Hi, in this tutorial, I’ll show you how to build a 3D Processing sketch that uses planetary motion. We’ll get most of the code from an unlikely place – the open-source audio software Csound.

Csound has a planet opcode- a routine that does exactly what we need it to – output x,y,z values for the planetary motion equation!

We’ll investigate the source Csound code and extract the planetary motion equation.

Continue reading

Creative developer