×

Close

- Design And Analysis Of Algorithm - DAA
- Note
- Computer Science Engineering
- B.Tech
- 5 Topics
**1320 Views**- 21 Offline Downloads
- Uploaded 9 months ago

Touch here to read

Page-1

Topic:

Vivekananda College e of Engineering & Technolog ogy N Nehru nagar post, Puttur, D.K. 5742013 Lecture Notes on 15CS43 Design and Analysis lysis of Algorithms (CBCS Scheme) Prepared by Mr. Harivinod N Dept. of Computer C Science and Engineering, VCET Puttur Jan 2017 ms Module-1 : Introduction to Algorithms Contents 1. Introduction 1.1. What is an Algo gorithm? ecification 1.2. Algorithm Speci work 1.3. Analysis Framewo ysis 2. Performance Analysi xity 2.1. Space complexit ity 2.2. Time complexity ons 3. Asymptotic Notation on 3.1. Big-Oh notation on 3.2. Omega notation 3.3. Theta notation tion 3.4. Little-oh notatio nalysis 3.5. Mathematical ana o rs roblem Types 4. Important Pro 4.1. Sorting ing 4.2. Searching processing 4.3. String pro Problems 4.4. Graph Pro natorial Problems 4.5. Combinat al D Data Structures 5. Fundamental near Data Structures 5.1. Linear 5.2. Graphs 5.3. Trees Dictionaries. 5.4. Sets andd D

troduction Lecture Notes | 15CS43 – Design & Analysis of Algorithms | Module 1: Introdu 1. Introduction 1.1. What is an Algorithm? et of instructions to solve a particular proble lem. In addition, all An algorithm is a finite set following criteria: algorithms must satisfy the fol ore quantities are externally supplied. a. Input. Zero or mor one quantity is produced. b. Output. At least on ch instruction is clear and unambiguous. It mus ust be perfectly clear c. Definiteness. Each what should be don one. hen for all cases, the d. Finiteness. If wee ttrace out the instruction of an algorithm, the ates after a finite number of steps. algorithm terminate very instruction must be very basic so that it ca can be carried out, in e. Effectiveness. Ever person using only pencil and paper. It is not ot enough that each principle, by a per inite as in criterion c; it also must be feasible. operation be defini Algorithm design and analy lysis process - We now briefly discuss a seq equence of steps one signing and analyzing an algorithm typically goes through in desig • Understanding the Prob oblem - From a practical perspective, the first rst thing you need to do before designing an al algorithm is to understand completely the pr problem given. An input to an algorithm spec ecifies an instance of the problem the algorithm thm solves. It is very important to specify exactl ctly the set of instances the algorithm needs to handle. • Ascertaining the Capab bilities of the Computational Device - Onc nce you completely understand a problem, you ou need to ascertain the capabilities of the com computational device the algorithm is intended ded for. Select appropriate model from seq equential or parallel programming model. Prerpared by Harivinod N Page|1.2

troduction Lecture Notes | 15CS43 – Design & Analysis of Algorithms | Module 1: Introdu • Choosing between Exac act and Approximate Problem Solving - The T next principal decision is to choose betw tween solving the problem exactly and solving ing it approximately. Because, there are importa rtant problems that simply cannot be solvedd eexactly for most of their instances and somee oof the available algorithms for solving a prob oblem exactly can be unacceptably slow because use of the problem’s intrinsic complexity. • Algorithm Design Tech chniques - An algorithm design techniquee (or “strategy” or “paradigm”) is a generall aapproach to solving problems algorithmically lly that is applicable to a variety of problemss ffrom different areas of computing. They pro provide guidance for designing algorithms for or new problems, i.e., problems for which tthere is no known satisfactory algorithm. • Designing an Algorithm m and Data Structures - One should pay ay close attention to choosing data structuress aappropriate for the operations performed byy the algorithm. For example, the sieve of Erat ratosthenes would run longer if we used a linke ked list instead of an array in its implementation ion. Algorithms + Data Structures = Program ams • Methods of Specifying an Algorithm- Once you have designed an al algorithm; you need to specify it in some fas fashion. These are the two options that are re most widely used nowadays for specifyingg aalgorithms. Using a natural language hass aan obvious appeal; however, the inherent am ambiguity of any natural language makes a concise and clear description of algorithmss surprisingly difficult. Pseudocode is a mi mixture of a natural language and programmin ing language like constructs. Pseudocode is us usually more precise than natural language, and nd its usage often yields more succinct algorithm thm descriptions. • Proving an Algorithm’s ’s Correctness - Once an algorithm has beenn sspecified, you have to prove its correctness.. T That is, you have to prove that the algorithm hm yields a required result for every legitimate te input in a finite amount of time. For some algorithms, a proof of correctness is quite easy asy; for others, it can be quite complex. A com ommon technique for proving correctness is to use mathematical induction because an alg lgorithm’s iterations provide a natural sequence ce of steps needed for such proofs. • Analyzing an Algorithm m - After correctness, by far the most importa rtant is efficiency. In fact, there are two kindss oof algorithm efficiency: time efficiency, indic dicating how fast the ce efficiency, indicating how much extra memo mory it uses. Another algorithm runs, and space desirable characteristic of an algorithm is simplicity. Unlike efficien iency, which can be precisely defined and inve vestigated with mathematical rigor, simplicity, ty, like beauty, is to a considerable degree in the he eye of the beholder. • ately implemented as Coding an Algorithm - Most algorithms are destined to be ultimate plementing an algorithm correctly is necessary ry but not sufficient: computer programs. Imple you would not like to dim iminish your algorithm’s power by an inefficie ient implementation. rovide a certain safety net in this regard, especi ecially when they are Modern compilers do prov used in their code optimiza ization mode. Prerpared by Harivinod N Page|1.3

troduction Lecture Notes | 15CS43 – Design & Analysis of Algorithms | Module 1: Introdu tion 1.2. Algorithm Specification ed in An algorithm can be specified 1) 2) 3) 4) Simple English Graphical representatio tion like flow chart age like c++ / java Programming language ve methods. Combination of above Using the combination of si simple English and C++, the algorithm for selection sort is specified as follows. In C++ the same algorithm can be specified as follows defined data type. Here Type is a basic or user de Recursive algorithms re if the same algorithm is invokedd iin the body (direct An algorithm is said to be recursive aid to be indirect recursive if it calls another er algorithm which in recursive). Algorithm A is said turn calls A. tation n! = n * (n-1)! Example 1: Factorial computa cient computation Example 2: Binomial coefficie problem Example 3: Tower of Hanoii pr nerator Example 4: Permutation Gene Prerpared by Harivinod N Page|1.4

## Leave your Comments