Chapter 1. Introduction

1.1 Need for studying algorithms The study of algorithms is the cornerstone of computer science.It can be recognized as the core of computer science. Computer programs would not exist without algorithms. With computers becoming an essential part of our professional personal life s, studying algorithms becomes a necessity, more so for computer science engineers. Another reason for studying algorithms is that if we know a standard set of important algorithms ,They further our analytical skills help us in developing new algorithms for required applications 1.2 ALGORITHM An algorithm is finite set of instructions that is followed, accomplishes a particular task. In addition, all algorithms must satisfy the following criteria 1. Input. Zero or more quantities are externally supplied. 2. Output. At least one quantity is produced. 3. Definiteness. Each instruction is clear and produced. 4. Finiteness. If we trace out the instruction of an algorithm, then for all cases, the algorithm terminates after a finite number of steps. 5. Effectiveness. Every instruction must be very basic so that it can be carried out, in principal, by a person using only pencil and paper. It is not enough that each operation be definite as in criterion 3 it also must be feasible.

COMPUTER

Fig 1.a. An algorithm is composed of a finite set of steps, each of which may require one or more operations. The possibility of a computer carrying out these operations necessitates that certain constraints be placed on the type of operations an algorithm can include. The fourth criterion for algorithms we assume in this book is that they terminate after a finite number of operations. Criterion 5 requires that each operation be effective each step must be such that it can, at least in principal, be done by a person using pencil and paper in a finite amount of time. Performing arithmetic on integers is an example of effective operation, but arithmetic with real numbers is not, since some values may be expressible only by infinitely long decimal expansion. Adding two such numbers would violet the effectiveness property.

Algorithms that are definite and effective are also called computational procedures.

The same algorithm can be represented in same algorithm can be represented in several ways

Several algorithms to solve the same problem

Different ideas different speed

Example

Problem GCD of Two numbers m,n Input specifiastion Two inputs,nonnegative,not both zero