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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

18 Chap. 1 <strong>D<strong>at</strong>a</strong> <strong>Structures</strong> <strong>and</strong> <strong>Algorithm</strong>sto write it down, nor implement it as a computer program. Most languages fordescribing algorithms (including English <strong>and</strong> “pseudocode”) provide someway to perform repe<strong>at</strong>ed actions, known as iter<strong>at</strong>ion. Examples of iter<strong>at</strong>ionin programming languages include the while <strong>and</strong> for loop constructs ofJava. Iter<strong>at</strong>ion allows for short descriptions, with the number of steps actuallyperformed controlled by the input.5. It must termin<strong>at</strong>e. In other words, it may not go into an infinite loop.Programs: We often think of a computer program as an instance, or concreterepresent<strong>at</strong>ion, of an algorithm in some programming language. In this book,nearly all of the algorithms are presented in terms of programs, or parts of programs.N<strong>at</strong>urally, there are many programs th<strong>at</strong> are instances of the same algorithm,because any modern computer programming language can be used to implementthe same collection of algorithms (although some programming languagescan make life easier for the programmer). To simplify present<strong>at</strong>ion, I often usethe terms “algorithm” <strong>and</strong> “program” interchangeably, despite the fact th<strong>at</strong> they arereally separ<strong>at</strong>e concepts. By definition, an algorithm must provide sufficient detailth<strong>at</strong> it can be converted into a program when needed.The requirement th<strong>at</strong> an algorithm must termin<strong>at</strong>e means th<strong>at</strong> not all computerprograms meet the technical definition of an algorithm. Your oper<strong>at</strong>ing system isone such program. However, you can think of the various tasks for an oper<strong>at</strong>ing system(each with associ<strong>at</strong>ed inputs <strong>and</strong> outputs) as individual problems, each solvedby specific algorithms implemented by a part of the oper<strong>at</strong>ing system program, <strong>and</strong>each one of which termin<strong>at</strong>es once its output is produced.To summarize: A problem is a function or a mapping of inputs to outputs.An algorithm is a recipe for solving a problem whose steps are concrete <strong>and</strong> unambiguous.<strong>Algorithm</strong>s must be correct, of finite length, <strong>and</strong> must termin<strong>at</strong>e for allinputs. A program is an instanti<strong>at</strong>ion of an algorithm in a programming language.1.5 Further ReadingAn early authorit<strong>at</strong>ive work on d<strong>at</strong>a structures <strong>and</strong> algorithms was the series ofbooks The Art of <strong>Computer</strong> Programming by Donald E. Knuth, with Volumes 1<strong>and</strong> 3 being most relevant to the study of d<strong>at</strong>a structures [Knu97, Knu98]. A modernencyclopedic approach to d<strong>at</strong>a structures <strong>and</strong> algorithms th<strong>at</strong> should be easyto underst<strong>and</strong> once you have mastered this book is <strong>Algorithm</strong>s by Robert Sedgewick[Sed11]. For an excellent <strong>and</strong> highly readable (but more advanced) teachingintroduction to algorithms, their design, <strong>and</strong> their analysis, see Introduction to <strong>Algorithm</strong>s:A Cre<strong>at</strong>ive Approach by Udi Manber [Man89]. For an advanced, encyclopedicapproach, see Introduction to <strong>Algorithm</strong>s by Cormen, Leiserson, <strong>and</strong>Rivest [CLRS09]. Steven S. Skiena’s The <strong>Algorithm</strong> Design Manual [Ski10] pro-

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

Saved successfully!

Ooh no, something went wrong!