design and analysis of algorithms 18cs42 module 1
play

Design and Analysis of Algorithms 18CS42 Module 1: Introduction to - PowerPoint PPT Presentation

Design and Analysis of Algorithms 18CS42 Module 1: Introduction to Algorithms Module 1: Introduction to Algorithms Harivinod N Harivinod N Dept. of Computer Science and Engineering Dept. of Computer Science and Engineering VCET VCET Puttur


  1. Design and Analysis of Algorithms 18CS42 Module 1: Introduction to Algorithms Module 1: Introduction to Algorithms Harivinod N Harivinod N Dept. of Computer Science and Engineering Dept. of Computer Science and Engineering VCET VCET Puttur Puttur

  2. Course Outcome • At the end of the course, you will be able to; At the end of the course, you will be able to; 1. Estimate the computational complexity of different 1. Estimate the computational complexity of different algorithms along with its representation notations. algorithms along with its representation notations. 2. Design and analyze problem solving using divide and 2. Design and analyze problem solving using divide and conquer strategy conquer strategy 3. Apply greedy method to solve problems. 3. Apply greedy method to solve problems. 4. Apply dynamic programming to solve problems using the 4. Apply dynamic programming to solve problems using the solutions of similar subproblems. solutions of similar subproblems. 5. Design and apply backtracking technique for problem 5. Design and apply backtracking technique for problem solving solving Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 2

  3. Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 3

  4. Algorithm Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 4

  5. al-Khorezmi • Muhammad ibn Musa al-Khwarizmi Muhammad ibn Musa al-Khwarizmi • The Father of Algebra The Father of Algebra • Persian Mathematician Persian Mathematician Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 5

  6. How to prepare tea? Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 6

  7. How to prepare Maggi noodles? 1. 1. Take one and a half cup of Water in a pan. Take one and a half cup of Water in a pan. 2. 2. Heat the pan on medium flame. Heat the pan on medium flame. 3. 3. When the Water comes to boil, add the Maggi to the pan. When the Water comes to boil, add the Maggi to the pan. 4. 4. Cover it with a lid for a minute. Cover it with a lid for a minute. 5. 5. After a minute, uncover the lid and add the tastemaker to After a minute, uncover the lid and add the tastemaker to the pan. the pan. 6. 6. Mix it well, Without breaking the Noodles. Mix it well, Without breaking the Noodles. 7. 7. Just when all of your Water is boiled, switch off the flame. Just when all of your Water is boiled, switch off the flame. 8. 8. Enjoy the hot Maggi. Enjoy the hot Maggi. Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 7

  8. How Kingfisher catches a fish efficiently? Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 8

  9. Shortest Distance between two cities Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 9

  10. Text Book -1 Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 10

  11. Text Book -2 Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 11

  12. Course Website: www.techjourney.in Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 12

  13. Module 1 – Outline Introduction to Algorithms 1. Introduction 1. Introduction 2. Performance Analysis 2. Performance Analysis 3. Asymptotic Notations 3. Asymptotic Notations 4. Mathematical analysis of Non-Recursive algorithms 4. Mathematical analysis of Non-Recursive algorithms 5. Mathematical analysis of Recursive algorithms 5. Mathematical analysis of Recursive algorithms 6. Important Problem Types 6. Important Problem Types 7. Fundamental Data Structures 7. Fundamental Data Structures Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 13

  14. Module 1 – Outline Introduction to Algorithms 1. Introduction 1. Introduction 2. Performance Analysis 2. Performance Analysis 3. Asymptotic Notations 3. Asymptotic Notations 4. Mathematical analysis of Non-Recursive algorithms 4. Mathematical analysis of Non-Recursive algorithms 5. Mathematical analysis of Recursive algorithms 5. Mathematical analysis of Recursive algorithms 6. Important Problem Types 6. Important Problem Types 7. Fundamental Data Structures 7. Fundamental Data Structures Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 14

  15. What is an Algorithm? • An algorithm is a finite sequence of unambiguous An algorithm is a finite sequence of unambiguous instructions to solve a particular problem. instructions to solve a particular problem. • In addition, all algorithms must satisfy the following In addition, all algorithms must satisfy the following criteria: criteria: – Input: Zero or more quantities are externally supplied. Input: Zero or more quantities are externally supplied. – Output: At least one quantity is produced. Output: At least one quantity is produced. – Definiteness: Each instruction is clear and unambiguous. Definiteness: Each instruction is clear and unambiguous. – Finiteness: algorithm terminates after a finite number of Finiteness: algorithm terminates after a finite number of steps. steps. – Correctness Correctness – Effectiveness Effectiveness Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 15

  16. Algorithm design and analysis process Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 16

  17. Algorithm specification • An algorithm can be specified in An algorithm can be specified in 1. Simple English 1. Simple English 2. Graphical representation like flow chart 2. Graphical representation like flow chart 3. Programming language like c++ / java 3. Programming language like c++ / java 4. Combination of above methods. 4. Combination of above methods. Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 17

  18. Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 18

  19. Recursive Algorithm • An algorithm is said to be recursive if the same algorithm is An algorithm is said to be recursive if the same algorithm is invoked in the body (direct recursive). invoked in the body (direct recursive). • Algorithm A is said to be indirect recursive if it calls another Algorithm A is said to be indirect recursive if it calls another algorithm which in turn calls A. algorithm which in turn calls A. • Example 1: Factorial computation n! = n * (n-1)! Example 1: Factorial computation n! = n * (n-1)! • Example 2: Binomial coefficient computation • Example 2: Binomial coefficient computation • Example 3: Tower of Hanoi problem Example 3: Tower of Hanoi problem • Example 4: Permutation Generator Example 4: Permutation Generator Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 19

  20. Module 1 – Outline Introduction to Algorithms 1. Introduction 1. Introduction 2. Performance Analysis 2. Performance Analysis 3. Asymptotic Notations 3. Asymptotic Notations 4. Mathematical analysis of Non-Recursive algorithms 4. Mathematical analysis of Non-Recursive algorithms 5. Mathematical analysis of Recursive algorithms 5. Mathematical analysis of Recursive algorithms 6. Important Problem Types 6. Important Problem Types 7. Fundamental Data Structures 7. Fundamental Data Structures Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 20

  21. Performance Analysis • Space complexity Space complexity – Space Complexity of an algorithm is total space taken by Space Complexity of an algorithm is total space taken by the algorithm with respect to the input size. the algorithm with respect to the input size. – Space complexity includes both Auxiliary space and space Space complexity includes both Auxiliary space and space used by input. used by input. • Time complexity • Time complexity Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 21

  22. Time Complexity • Execution time or run-time of the program Execution time or run-time of the program is refereed as its time complexity is refereed as its time complexity • This is the sum of the time taken to This is the sum of the time taken to execute all instructions in the program. execute all instructions in the program. • But, We count only the number of steps in But, We count only the number of steps in the program. Why? the program. Why? • How to count? How to count? – Two ways Two ways Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 22

  23. Method-1 • Introduce a count variable • Increment count for every operation Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 23

  24. Method-2 • Count the steps per execution for every Count the steps per execution for every line of code line of code • Note the frequency of execution of Note the frequency of execution of every line and find the total steps. every line and find the total steps. Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 24

  25. Method-2 Harivinod N 18CS42-Design and Analysis of Algorithms Feb-May 2020 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend