Saturday, December 29, 2012

algorithm introduction

http://mitpress.mit.edu/algorithms/, links to solutions for
a few of the problems and exercises.
Based on many requests, we changed the syntax (as it were) of our pseudocode.
We now use “D” to indicate assignment and “==” to test for equality, just as C,
C++, Java, and Python do. Likewise, we have eliminated the keywords do and
then and adopted “//” as our comment-to-end-of-line symbol. We also now use
dot-notation to indicate object attributes. Our pseudocode remains procedural,
rather than object-oriented. In other words, rather than running methods on
objects, we simply call procedures, passing objects as parameters.
Informally, an algorithm is any well-defined computational procedure that takes
some value, or set of values, as input and produces some value, or set of values, as
output. An algorithm is thus a sequence of computational steps that transform the
input into the output.
The algorithm describes a specific computational procedure
for achieving that input/output relationship.
An algorithm is said to be correct if, for every input instance, it halts with the
correct output.
A data structure is a way to store
and organize data in order to facilitate access and modifications.
The running time of an algorithm on a particular input is the number of primitive
operations or “steps” executed.
When a for or while loop
exits in the usual way (i.e., due to the test in the loop header), the test is executed
one time more than the loop body. We assume that comments are not executable
statements, and so they take no time.
For the remainder of this book, though, we shall usually concentrate on
finding only the worst-case running time, that is, the longest running time for any
input of size n.
We usually consider one algorithm to be more efficient than another if its worstcase
running time has a lower order of growth.
2.3 Designing algorithms

No comments:

Post a Comment