Lecture Notes on Algorithm - Algorithm Analysis and Design | CPSC 5115G, Study notes of Computer Science

Material Type: Notes; Professor: Bosworth; Class: Algorithm Analysis and Design; Subject: Computer Science; University: Columbus State University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/04/2009

koofers-user-yb7
koofers-user-yb7 🇺🇸

5

(1)

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Slide 1 of 6 pages
Algorithm
Definition: An algorithm is a finite set of instructions which, if followed, will
accomplish a particular task. In addition every algorithm must satisfy the
following criteria:
i) input: there are zero or more quantities which are externally
supplied;
ii) output: at least one quantity is produced;
`iii) definiteness: each instruction must be clear and unambiguous;
iv) finiteness: if we trace out the instructions of the algorithm, then for
all valid cases the algorithm will terminate after a finite
number of steps;
v) effectiveness: every instruction must be sufficiently basic that it can
in principle be carried out by a person using only a pencil and
paper. It is not enough that each operation be definite as in
(iii), but it must be feasible. [Hor76]
pf3
pf4
pf5

Partial preview of the text

Download Lecture Notes on Algorithm - Algorithm Analysis and Design | CPSC 5115G and more Study notes Computer Science in PDF only on Docsity!

Algorithm

Definition: An algorithm is a finite set of instructions which, if followed, will accomplish a particular task. In addition every algorithm must satisfy the following criteria: i) input : there are zero or more quantities which are externally supplied; ii) output : at least one quantity is produced; `iii) definiteness : each instruction must be clear and unambiguous; iv) finiteness : if we trace out the instructions of the algorithm, then for all valid cases the algorithm will terminate after a finite number of steps; v) effectiveness : every instruction must be sufficiently basic that it can in principle be carried out by a person using only a pencil and paper. It is not enough that each operation be definite as in (iii), but it must be feasible. [Hor76]

Algorithmic Effectiveness

Note the above requirement that an algorithm “in principle be carried out by a person using only a pencil and paper”. This limits the operations that are allowable in a “pure algorithm”. The basic list is: addition and subtraction; multiplication and division; and the operations immediately derived from these. One might argue for expansion of this list to include a few other operations that can be done by pencil and paper. I know an easy algorithm for taking the square root of integers, and can do that with a pencil on paper. However, this algorithm will produce an exact answer for only those integers that are the square of other integers; their square root must be an integer. Operations, such as the trigonometric functions, are not basic operations. These can appear in algorithms only to the extent that they are understood to represent a sequence of basic operations that can be well defined.

Heuristics vs. Algorithms

Computer Science Definition A heuristic is a procedure, similar to an algorithm, that often produces a correct answer, but is not guaranteed to produce anything. Operations Research Definition Problems are usually optimization problems ; either maximize profits and minimize costs. An algorithm is defined in the sense of computer science (previous slide) with the additional requirement that it always produces an optimal answer. A heuristic is a procedure that often produces an optimal answer, but cannot be proven to do so. NOTE: Both algorithms and heuristics can contain high–level statements that cannot be implemented directly in common programming languages; e.g. “sort the array low–to–high”.

Euclid’s Algorithm

Compute the greatest common divisor of two non–negative integers. For two integers K  0 and N  0, we say that “K divides N”, equivalently “N is a multiple of K”, if N is an integral multiple of K: N = KL. This property is denoted “K | N”, which is read as “K divides N”. The greatest common divisor of two integers M  0 and N  0, denoted gcd(M, N) is defined as follows.

  1. gcd(M, 0) = gcd(0, M) = M
  2. gcd(M, N) = K, such that a) K | M b) K | N c) K is the largest integer with this property. Euclid’s Algorithm: gcd(M, N) = gcd (N, M mod N)