Computer Notes Useful for Students

Topics: Sorting algorithm, Algorithm, Analysis of algorithms Pages: 126 (38454 words) Published: June 15, 2012
Lecture Notes

CMSC 251

CMSC 251: Algorithms1 Spring 1998 Dave Mount Lecture 1: Course Introduction (Tuesday, Jan 27, 1998)
Read: Course syllabus and Chapter 1 in CLR (Cormen, Leiserson, and Rivest). What is algorithm design? Our text deﬁnes an algorithm to be any well-deﬁned computational procedure that takes some values as input and produces some values as output. Like a cooking recipe, an algorithm provides a step-by-step method for solving a computational problem. A good understanding of algorithms is essential for a good understanding of the most basic element of computer science: programming. Unlike a program, an algorithm is a mathematical entity, which is independent of a speciﬁc programming language, machine, or compiler. Thus, in some sense, algorithm design is all about the mathematical theory behind the design of good programs. Why study algorithm design? There are many facets to good program design. Good algorithm design is one of them (and an important one). To be really complete algorithm designer, it is important to be aware of programming and machine issues as well. In any important programming project there are two major types of issues, macro issues and micro issues. Macro issues involve elements such as how does one coordinate the efforts of many programmers working on a single piece of software, and how does one establish that a complex programming system satisﬁes its various requirements. These macro issues are the primary subject of courses on software engineering. A great deal of the programming effort on most complex software systems consists of elements whose programming is fairly mundane (input and output, data conversion, error checking, report generation). However, there is often a small critical portion of the software, which may involve only tens to hundreds of lines of code, but where the great majority of computational time is spent. (Or as the old adage goes: 80% of the execution time takes place in 20% of the code.) The micro issues in programming involve how best to deal with these small critical sections. It may be very important for the success of the overall project that these sections of code be written in the most efﬁcient manner possible. An unfortunately common approach to this problem is to ﬁrst design an inefﬁcient algorithm and data structure to solve the problem, and then take this poor design and attempt to ﬁne-tune its performance by applying clever coding tricks or by implementing it on the most expensive and fastest machines around to boost performance as much as possible. The problem is that if the underlying design is bad, then often no amount of ﬁne-tuning is going to make a substantial difference. As an example, I know of a programmer who was working at Boeing on their virtual reality system for the 777 project. The system was running unacceptably slowly in spite of the efforts of a large team of programmers and the biggest supercomputer available. A new programmer was hired to the team, and his ﬁrst question was on the basic algorithms and data structures used by the system. It turns out that the system was based on rendering hundreds of millions of polygonal elements, most of which were 1 Copyright, David M. Mount, 1998, Dept. of Computer Science, University of Maryland, College Park, MD, 20742. These lecture notes were prepared by David Mount for the course CMSC 251, Algorithms, at the University of Maryland, College Park. Permission to use, copy, modify, and distribute these notes for educational purposes and without fee is hereby granted, provided that this copyright notice appear in all copies.

1

Lecture Notes

CMSC 251

invisible at any point in time. Recognizing this source of inefﬁciency, he redesigned the algorithms and data structures, recoded the inner loops, so that the algorithm concentrated its efforts on eliminating many invisible elements, and just drawing the few thousand visible elements. In a matter of two weeks he had a system that...