Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION. What is an algorithm? What is a Problem?

Similar presentations


Presentation on theme: "INTRODUCTION. What is an algorithm? What is a Problem?"— Presentation transcript:

1 INTRODUCTION

2 What is an algorithm?

3 What is a Problem?

4 Problem Instance Determining GCD is a problem – How many actual problems? GCD of 1 and 2 ? GCD of 234 and 42? More? Obviously yes. Problem instance – A problem with a specific input – E.g., find a GCD of 42 and 14

5 Purpose of this class

6 Calculating Fibonacci Sequence Fibonacci sequence – 1, 1, 2, 3, 5, 7, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584

7 The Problem Input: – a positive number N Output: – F n (the n th Fibonacci Number) Example instances – Ex. 1: N = 10 – Ex. 2: N = 15 – Ex. 3: N = 0 N = -4 is not an instances of this problem!!!

8 Approach 1 Array based method: dynamic programming on linear structure (linear time) 11235813213455

9 Approach 2 method: Recursive (exponential time) F(9) F(8)F(7) F(6) F(5) … …

10 Approach 3 Method: Divide and Conquer (logarithmic)

11 Approach 3 Find exponential Method: Divide and Conquer (logarithmic)

12 Approach 4 Method: Closed form solution Golden Ratio

13 Conclusion Difference Design  Difference Performance This class emphasizes on designing “efficient algorithm”

14 Algorithm Again It is the essence of the computation

15 Side Note on Algorithm Named after a Persian mathematician “Abū ʿAbdallāh Muḥammad ibn Mūsā al-Khwārizmī” Wrote book on linear equation Introduce number 0

16 TOPICS OVERVIEW Analysis part

17 Asymptotic Notation Measurement of “efficiency” of algorithms – How to compare two algorithms – How to predict behavior of the algorithm

18 Big O analysis How to determine Big O of some code Recurrent Relation

19 NP-Complete What computer could solve – Efficiently – Inefficiently The difference between “Efficiency” and “Inefficiency”

20 TOPICS OVERVIEW Synthesis part

21 Divide and Conquer Solve an instance of the problem by dividing it into smaller instances – Based on induction Example Problems: – Sorting (Quick Sort & Merge Sort) – Maximum Contiguous Sum of Subsequence – Modulo Exponential – Closest Pair

22 Dynamic Programming Aim to reduce redundancy in computation For the case when there are several overlapping sub-problems Example Problems: – Fibonacci Number – Binomial Coefficient – Matrix Chain Multiplication – Longest Common Subsequence – Largest Square in Binary Picture (Island problem)

23 Greedy Algorithm Solve the problem by doing the best for the current step Proof of correctness Example Problems: – Minimum Spanning Tree Prim’s Algorithm Kruskal’s Algorithm

24 Graph Algorithm Algorithm related to graph structure – Breadth First Search – Depth First Search – Shortest Path

25 Search Solve the problem by enumeration – Systematical enumeration – Performance improvement Branch and Bound Backtracking


Download ppt "INTRODUCTION. What is an algorithm? What is a Problem?"

Similar presentations


Ads by Google