11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Prefacexviithe form ofcalls to methods in class Assert. Method Assert.notFalsetakes a Boolean expression. If this expression evalu<strong>at</strong>es to false, then a messageis printed <strong>and</strong> the program termin<strong>at</strong>es immedi<strong>at</strong>ely. Method Assert.notNulltakes a reference to class Object, <strong>and</strong> termin<strong>at</strong>es the program if the value ofthe reference is null. (To be precise, they throw an IllegalArgument-Exception, which will termin<strong>at</strong>e the program unless the programmer takes actionto h<strong>and</strong>le the exception.) Termin<strong>at</strong>ing a program when a function receives abad parameter is generally considered undesirable in real programs, but is quiteadequ<strong>at</strong>e for underst<strong>and</strong>ing how a d<strong>at</strong>a structure is meant to oper<strong>at</strong>e. In real programmingapplic<strong>at</strong>ions, Java’s exception h<strong>and</strong>ling fe<strong>at</strong>ures should be used to dealwith input d<strong>at</strong>a errors. However, assertions provide a simpler mechanism for indic<strong>at</strong>ingrequired conditions in a way th<strong>at</strong> is both adequ<strong>at</strong>e for clarifying how a d<strong>at</strong>astructure is meant to oper<strong>at</strong>e, <strong>and</strong> is easily modified into true exception h<strong>and</strong>ling.I make a distinction in the text between “Java implement<strong>at</strong>ions” <strong>and</strong> “pseudocode.”Code labeled as a Java implement<strong>at</strong>ion has actually been compiled <strong>and</strong>tested on one or more Java compilers. Pseudocode examples often conform closelyto Java syntax, but typically contain one or more lines of higher-level description.Pseudocode is used where I perceived a gre<strong>at</strong>er pedagogical advantage to a simpler,but less precise, description.Exercises <strong>and</strong> Projects: Proper implement<strong>at</strong>ion <strong>and</strong> analysis of d<strong>at</strong>a structurescannot be learned simply by reading a book. You must practice by implementingreal programs, constantly comparing different techniques to see wh<strong>at</strong> really worksbest in a given situ<strong>at</strong>ion.One of the most important aspects of a course in d<strong>at</strong>a structures is th<strong>at</strong> it iswhere students really learn to program using pointers <strong>and</strong> dynamic memory alloc<strong>at</strong>ion,by implementing d<strong>at</strong>a structures such as linked lists <strong>and</strong> trees. It is oftenwhere students truly learn recursion. In our curriculum, this is the first course wherestudents do significant design, because it often requires real d<strong>at</strong>a structures to motiv<strong>at</strong>esignificant design exercises. Finally, the fundamental differences betweenmemory-based <strong>and</strong> disk-based d<strong>at</strong>a access cannot be appreci<strong>at</strong>ed without practicalprogramming experience. For all of these reasons, a d<strong>at</strong>a structures course cannotsucceed without a significant programming component. In our department, the d<strong>at</strong>astructures course is one of the most difficult programming course in the curriculum.Students should also work problems to develop their analytical abilities. I provideover 450 exercises <strong>and</strong> suggestions for programming projects. I urge readersto take advantage of them.Contacting the Author <strong>and</strong> Supplementary M<strong>at</strong>erials: A book such as thisis sure to contain errors <strong>and</strong> have room for improvement. I welcome bug reports<strong>and</strong> constructive criticism. I can be reached by electronic mail via the Internet <strong>at</strong>shaffer@vt.edu. Altern<strong>at</strong>ively, comments can be mailed to

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!