×

Close

- Design And Analysis Of Algorithm - DAA
- Note
**JNTUK KAKINADA - JNTUK**- 4 Topics
**203 Views**- Uploaded 6 months ago

Touch here to read

Page-1

Topic:

Design and Analysis of Algorithms UNIT – I ALGORITHM Informal Definition: An Algorithm is any well-defined computational procedure that takes some value or set of values as Input and produces a set of values or some value as output. Thus algorithm is a sequence of computational steps that transforms the i/p into the o/p. Formal Definition: An Algorithm is a finite set of instructions that, if followed, accomplishes a particular task. All algorithms should satisfy the following criteria. INPUT Zero or more quantities are externally supplied. OUTPUT At least one quantity is produced. DEFINITENESS Each instruction is clear and unambiguous. FINITENESS If we trace out the instructions of an algorithm, then for all cases, the algorithm terminates after a finite number of steps. 5. EFFECTIVENESS Every instruction must very basic so that it can be carried out, in principle, by a person using only pencil & paper. 1. 2. 3. 4. Issues or study of Algorithm: How to device or design an algorithm creating and algorithm. How to express an algorithm definiteness. How to analysis an algorithm time and space complexity. How to validate an algorithm fitness. Testing the algorithm checking for error. The study of Algorithms includes many important and active areas of research. There are four distinct areas of study one can identify 1. How to device algorithmsCreating an algorithm is an art which many never fully automated. A major goal is to study various design techniques that have proven to be useful. By mastering GVP College of Engineering for Women -1-

Design and Analysis of Algorithms these design strategies, it will become easier for you to device new and useful algorithms. some of techniques may already be familiar, and some have been found to be useful. Dynamic programming is one technique. Some of the techniques are especially useful in fields other than computer science such as operations research and electrical engineering. 2. How to validate algorithms: Once an algorithm is devised, it is necessary to show that it computes the correct answer for all possible legal inputs. We refer to this process as algorithm validation. The algorithm need not as yet be expressed as a program. The purpose of validation is to assure us that this algorithm will work correctly independently. Once the validity of the method has been shown, a program can be written and a second phase begins. This phase is referred to as program proving or sometimes as program verification. A proof of correctness requires that the solution be stated in two forms. One form is usually as a program which is annotated by a set of assertions about the input and output variables of the program. These assertions are often expressed in the predicate calculus. The second form is called a specification, and this may also be expressed in the predicate calculus. A complete proof of program correctness requires that each statement of a programming language be precisely defined and all basic operations be proved correct. 3. How to analyze algorithms: As an algorithm is executed, it uses the computer's central processing unit (CPU) to perform operations and its memory to hold the program and data. Analysis of algorithms or performance analysis refers to the task of determining how much computing time and storage algorithms replace.we analyze the algorithm based on time and space complexity.The amount of time neede to run the GVP College of Engineering for Women -2-

Design and Analysis of Algorithms algorithm is called time complexity.The amount of memory neede to run the algorithm is called space complexity 4. How to test a program: Testing a program consists of two phases 1. Debugging 2. Profiling Debugging: It is the process of executing programs on sample data sets to determine whether faulty results occur and, if so to correct them. However, as E. Dijkstra has pointed out, “debugging can only point to the presence of errors, but not to the absence". Profiling: Profiling or performance measurement is the process of executing a correct program on data sets and measuring the time and space it takes to compute the results. Algorithm Specification: Algorithm can be described in three ways. 1. Natural language like English: When this way is choused care should be taken, we should ensure that each & every statement is definite. 2. Graphic representation called flowchart: This method will work well when the algorithm is small& simple. 3. Pseudo-code Method: This method describe algorithms as program, which resembles language like Pascal & algol. GVP College of Engineering for Women -3-

Design and Analysis of Algorithms Pseudo-Code Conventions for expressing algorithms: 1. Comments begin with // and continue until the end of line. 2. Blocks are indicated with matching braces {and}. 3. An identifier begins with a letter. The data types of variables are not explicitly declared. 4. Compound data types can be formed with records. Here is an example, Node. Record { data type – 1 data-1; . . . data type – n data – n; node * link; } Here link is a pointer to the record type node. Individual data items of a record can be accessed with and period. 5. Assignment of values to variables is done using the assignment statement. <Variable>:= <expression>; 6. There are two Boolean values TRUE and FALSE. Logical Operators AND, OR, NOT Relational Operators <, <=,>,>=, =, != 7. The following looping statements are employed. For, while and repeat-until While Loop: While < condition > do { <statement-1> . . GVP College of Engineering for Women -4-

## Leave your Comments