Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Data structures and algorithms: A comparative slice and dice -- er, review -- of 5 Java DS&A books

Laurence places 5 books on the chopping block. Find out which books avoid the cut

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 2 of 5

This book was published hot on the heels of its C++ flavor predecessor, Introduction to Data Structures and Algorithms with C++ (Prentice-Hall, 1997, also by Rowe). As a result, large chunks of text were taken verbatim from the earlier C++ text, but unfortunately (surprise, surprise), these do not apply or break down in the context of Java. (And I'm not even thinking about the omnipresent use of the term pointer when reference would be more accurate.) Then there are errors, such as the statement that "it is also necessary to initialize the individual elements of the [Object] array in the constructor. It was not necessary to do this in IntStack, since there we were dealing with primitive data types." Such phrases are comments about the author's Stack class constructor and prove that Rowe didn't understand how Java arrays work when he wrote that first sentence. When it comes to coding, standard Java naming conventions are consistently flouted and (logical) while loops are implemented with for( ; condition; modifier). A simple interface Comparable (to allow sorting of arbitrary items) is defined as:

public interface Comparable {
   public boolean lessThan(Comparable other);
   public boolean equalTo(Comparable other);
}


Why require an equalTo() when java.lang.Object already has an equals() with the right semantics? Worse, many of the implementations of data structures and algorithms are not reusable as-is because they're stuck, embedded in test harness code! Lastly, for a book that was launched in 1998, the author can't be tracking Java developments very closely; many of his exception-handling code uses the old-style (illegal by now) try-catch, which doesn't require blocks.

Java Algorithms by Scott Robert Ladd (McGraw-Hill)

Java Algorithms



This book can't possibly aim for the higher education market because its content thoroughly deviates from standard DS&A texts. Granted, the title only promises that the pages will focus on algorithms, which is a much broader subject matter than "merely" that of algorithms associated with classic data structures (many numerical algorithms, for example, have nothing to do with data structures). Anyway, from the overview I give below, you can judge for yourself which chapters can be considered the proverbial odd ones out, or even completely out of context for this type of book.

Chapter 1 "Sorting Things Out" hits the ground running by flying through coverage (and implementation) of Selection sort, Insertion sort, and Shell sort in just five pages. Almost the entire remainder of the chapter, nearly 20 pages, is devoted to the classic QuickSort. This heavily biased approach gave me the impression that the author judged QuickSort to be the only sorting algorithm worth writing about. It is also in these pages that you get to like or hate one particular aspect of the writing style that permeates this book: The author loves to use the first person at every opportunity ("I did", "I found", "My solution", "My requirements"). Indeed, the thesis of the book often comes across as "Hey, look at my cool library of classes." The unfortunate side effect of his style is that the presented material doesn't seem to have been crafted for, or targeted at, you, the reader, but rather amounts to documentation for some of the author's personal, but admittedly valuable, Java class library.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • Read all of Laurence's other great reviews. http://www.javaworld.com/common/jw-ti-bookreviews.html
  • Objectspace Inc.'s home page for their Java Generic Library (JGL). If you don't care about DS&A internals, but just need some free, industrial grade data structures and algorithms to use in your projects, then this has to be your first stop on the Web. http://www.objectspace.com/jgl/
  • Gamelan's Java resource directory contains numerous DS&A related resources. Use their search engine to home in on the goodies. http://www.developer.com/directories/pages/dir.java.html
  • John Wiley & Sons's online support pages for Goodrich and Tamassia's Data Structures and Algorithms in Java http://www.wiley.com/college/cs2java/
  • Addison-Wesley's product catalog entry for Weiss's Data Structures and Problem Solving Using Java. http://cseng.awl.com/bookdetail.qry?ISBN=0-201-54991-3&ptype=0
  • Glenn Rowe's books page, on which you can find links to the source code for his An Introduction to Data Structures and Algorithms with Java. http://alife.mic.dundee.ac.uk/growe/Books/index.html