Thursday, July 9, 2009

Searching and Sorting algorithms

I'm teaching second semester programming this summer. This is the class where classic algorithms such as binary search and QuickSort are introduced. These algorithms have a certain beauty about them that I really enjoy.

The book I'm using is Java Software Structures. This book is a solid CS2 textbook that covers searching and sorting in the order one would expect. I did not find the book to be outstanding, just a solid contender. I think the book would be outstanding if these issues were addressed:
  • The book uses generics, iterators, and other advanced features of Java without adequate coverage in the text. There is some coverage, but not enough. Many students coming out of a CS1 course won't be prepped enough to use them.
  • Code for searching and sorting is only given using generics. This forces students to solve 2 problems, what is the algorithm doing, and what's going on with the generics. I'd prefer the code first be introduced using an integer array, or even pseudo-code. If the code using generics was shown right after an integer array example, it would help emphasize what generics add.
  • I'd like to see some recursive algorithms, like binary search, be shown in non-recursive form. Otherwise students might think that the recursive algorithm is the only way to do it.
  • I'd like to see better images of the searching and sorting in progress.

Past that, not a bad book.