Design and Analysis of Algorithms - Chapter 11 Algorithm b An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time.
Design and Analysis of Algorithms - Chapter 12 Historical Perspective b Euclid’s algorithm for finding the greatest common divisor b Muhammad ibn Musa al-Khwarizmi – 9 th century mathematician
Design and Analysis of Algorithms - Chapter 13 Notion of algorithm “computer” Algorithmic solution problem algorithm inputoutput
Design and Analysis of Algorithms - Chapter 14 Example of computational problem: sorting b Statement of problem: Input: A sequence of n numbers Input: A sequence of n numbers Output: A reordering of the input sequence so that a ´ i ≤ a ´ j whenever i so that a ´ i ≤ a ´ j whenever i < j b Instance: The sequence b Instance: The sequence b Algorithms: Selection sortSelection sort Insertion sortInsertion sort Merge sortMerge sort (many others)(many others)
Design and Analysis of Algorithms - Chapter 15 Selection Sort Input: array a[1],…,a[n] Output: array a sorted in non-decreasing order b Algorithm: for i =1 to n swap a[i] with smallest of a[i],…a[n] see also pseudocode, section 3.1
Design and Analysis of Algorithms - Chapter 16 Some Well-known Computational Problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality testing b Traveling salesman problem b Knapsack problem b Chess b Towers of Hanoi b Program termination
Design and Analysis of Algorithms - Chapter 17 Basic Issues Related to Algorithms b How to design algorithms b How to express algorithms b Proving correctness b Efficiency Theoretical analysisTheoretical analysis Empirical analysisEmpirical analysis b Optimality
Design and Analysis of Algorithms - Chapter 18 Algorithm design strategies b Brute force b Divide and conquer b Decrease and conquer b Transform and conquer b Greedy approach b Dynamic programming b Backtracking and Branch and bound b Space and time tradeoffs
Design and Analysis of Algorithms - Chapter 19 Analysis of Algorithms b How good is the algorithm? CorrectnessCorrectness Time efficiencyTime efficiency Space efficiencySpace efficiency b Does there exist a better algorithm? Lower boundsLower bounds OptimalityOptimality
Design and Analysis of Algorithms - Chapter 110 What is an algorithm? b Recipe, process, method, technique, procedure, routine,… with following requirements: 1. Finiteness bterminates after a finite number of steps 2. Definiteness brigorously and unambiguously specified 3. Input bvalid inputs are clearly specified 4. Output bcan be proved to produce the correct output given a valid input 5. Effectiveness bsteps are sufficiently simple and basic
Design and Analysis of Algorithms - Chapter 111 Why study algorithms? b Theoretical importance the core of computer sciencethe core of computer science b Practical importance A practitioner’s toolkit of known algorithmsA practitioner’s toolkit of known algorithms Framework for designing and analyzing algorithms for new problemsFramework for designing and analyzing algorithms for new problems