Posts tagged with 'johnson-trotter'

PCPlus 263: Generating simple permutations

I write a monthly column for PCPlus, a computer news-views-n-reviews magazine in the UK (actually there are 13 issues a year — there's an Xmas issue as well — so it's a bit more than monthly). The column is called Theory Workshop and appears in the back of every issue. When I signed up, my editor and the magazine were gracious enough to allow me to reprint the articles here after say a year or so. After all, the PDFs do appear on each issue's DVD after a couple of months.

PCPlus logo This article was a fascinating one and as chance would have it — since it talks about "ringing the changes" — it appeared in the Christmas 2007 issue. Very festive, indeed. It was my eighth article for PCPlus and I was well into my stride structure-wise by now. Indeed this one has minimal changes from when I sent it up.

The subject is generating permutations or anagrams. The rationale for the article came from the anecdote I wrote about in the first few paragraphs (it was back in my early TurboPower days, if you want to know, say 15 years ago) and also from a presentation I'd found written by one of my favorite algorithm authors, Robert Sedgewick (and I lifted the couple of figures the article had from that presentation, although I did redesign them). Generating permutations seems like a simple algorithm, but it turns out to be hard to do it efficiently.

Not much else to say, really. I'll admit I haven't yet written an implementation of either the Johnson-Trotter Algorithm nor Heap's Algorithm. Perhaps I'll do it in another blog post.

(By the way, you try and find information about Heap's Algorithm without running into a lot of hits for the heap algorithm. Really, computer science researchers must change their name to something obscure before they invent and publish a new algorithm. Makes 21st century Google life a lot easier.)

This article first appeared in issue 263, Christmas 2007.

You can download the PDF here.

(Note to followers of this series. From this point on, I will publish these articles a year after they originally appeared. So the next one for January 2008 will appear at the end of this month.)

Album cover for Hello Waveforms Now playing:
Orbit, William - Surfin
(from Hello Waveforms)

Extras

Search

About Me

I'm Julian M Bucknall, the M because it's my middle initial and because I and the other Julian Bucknall (the movie guy) would like to differentiate ourselves.

I'm a programmer by trade, an actor by ambition, and an algorithms guy by osmosis. I write articles for PCPlus in my spare time, not that there's much of that.

Julian M Bucknall Apart from that, an ex-pat Brit, atheist, microbrew enthusiast, Pet Shop Boys fanboy, slide rule and HP calculator collector, amateur photographer, Altoids muncher.

DevExpress

I'm Chief Technology Officer at Developer Express, a software company that writes some great controls and tools for .NET and Delphi. I'm responsible for the technology oversight and vision of the company.

Validation

Validate markup as HTML5 (beta)     Validate CSS

Bottom swirl

Archives

May 2012 (4)
SMTWTFS
« Apr  
12345
6789101112
13141516171819
20212223242526
2728293031

Like this Archive Calendar widget? Download it here.

Social networking

The OUT Campaign

The OUT Campaign

My Tweets

  • Honest Movie Trailer of Phantom Menace http://t.co/sif8y4Ns and then Battleship, er, Transformers http://t.co/sif8y4Ns
  • Damn, Donna Summer and Chuck Brown both gone in the last 24 hours. Different types of music, sure, but enjoyed them both. :(
  • Just saw a company page showing a list of tweets with "Join the conversation" linked to their Twitter a/c. The tweets are 6 months old #fail
Bottom swirl