Presentation is loading. Please wait.

Presentation is loading. Please wait.

高等計算機演算法 Advanced Computer Algorithms

Similar presentations


Presentation on theme: "高等計算機演算法 Advanced Computer Algorithms"— Presentation transcript:

1 高等計算機演算法 Advanced Computer Algorithms
伍麗樵(Lih-Chyau Wuu) 雲林科技大學資工所

2 課程內容: Design Methods Analysis Methods The theory of NP-completeness

3 Design Methods The Greedy Method The Divide-and-Conquer strategy
Prune-and-Search Tree Searching strategy Dynamic Programming Approximation Algorithms Randomized Algorithms On-Line Algorithms

4 Analysis Methods Complexity of algorithms
Best, Average and Worst Case Analyses The Lower Bounds of Problems Amortized Analysis

5 教科書 Introduction to the Design and Analysis of Algorithms
R.C.T Lee R.C. Chang S.S. Tseng Y.T. Tsai Second Edition 旗標代理

6 分數 期中考 35% 期末考 35% 報告 %

7 Algorithm A number of rules, which are to be followed in a prescribed order, for solving a specific type of problems A method that can be used by a computer to solve a problem.

8 Computer Algorithm – Five Criteria
Input Output Finiteness Definiteness Effectiveness

9 Motivations of studying Algorithms
Algorithm is everywhere Use computers efficiently Optimal solution NP-complete problems(Decision problems) NP-hard problems(Optimization problems) next

10 Use computers efficiently
Sorting algorithms 11, 7, 14, 1, 5, 9, 10 ↓sort 1, 5, 7, 9, 10, 11, 14 Insertion sort Quick sort

11 Comparison with Two Algorithms Implemented on Two Computers

12 The study of Algorithms:
How to design algorithms How to validate algorithms How to analyze algorithms How to test a program

13 How to design algorithm
The study of algorithm design is almost a study of strategies

14 How to analyze algorithm
Measure the goodness of algorithms efficiency?(time/space) asymptotic notations: O( ) worst case average case amortized Measure the difficulty of problems NP-complete undecidable lower bound Is the algorithm optimal?

15 時間複雜度(time complexity)-worst case executing time
O(1):常數時間(constant time) O(n):線性時間(linear time) O(log2n):次線性時間(sub-linear time) O(n2):平方時間(quadratic time) O(n3):立方時間(cubic time) O(2n):指數時間(exponential time) O(1)<O(log2n)<O(n)<O(nlog2n)<O(n2)<O(n3)<O(2n)

16 Algorithm vs. Program Algorithm的表示方法 *虛擬碼(Pseudo Code)
SPARKS, PASCAL-like, Nature Language *流程圖表示法(Flow-chart representation) A program is the expression of an algorithm in a programming language

17 Background for Learning Algorithms
Clear brain Data structure Discrete mathematics

18 NP-complete problems:No efficient algorithms
Easy problem: polynomial-time algorithm Difficult problem: exponential-time algorithm Garey & Johnson “Computers & Intracability”

19 N1: Satisfiability Problem
Given a Boolean formula S, is there an assignment to make S true?  &: and !: or ~: not S=A& (~B !C) &~C S=A& ~A Worst case: n variables --> 2n combinations

20 N2: Bin Packing Problem C1 C2 C3 C4 C5 C6 C7 C8 7 1 3 4 1 3 3 8 B=15
B=15 How many bags are necessary?

21 N3: 0/1 Knapsack Problem M(weight limit)=14
Value 10 5 1 9 3 4 11 17 Weight 7 22 15 M(weight limit)=14 best solution: P1, P2, P3, P5(optimal) This problem is NP-complete.

22 N4: Traveling Salesperson Problem
Given a graph (vertex-city, edge-flying cost between two cities), the salesperson travels to every city once and only once, and the cost should also be minimal. Given a set of n planar points Find: A closed tour which includes all points exactly once such that its total length is minimized. This problem is NP-complete.

23 N5: Partition Problem Given: A set of positive integers S
Find: S1 and S2 such that S1S2=, S1S2=S, iS1i=iS2 i (partition into S1 and S2 such that the sum of S1 is equal to S2) e.g. S={1, 7, 10, 9, 5, 8, 3, 13} S1={1, 10, 9, 8} S2={7, 5, 3, 13} This problem is NP-complete.

24 N6: Art Gallery Problem Given an art gallery in the form of a polygon, determine the minimum number of guards and their placements such that the entire art gallery can be monitored by these guards.

25 P1: Minimal Spanning Tree Problem
Given a graph, find a spanning tree (a graph without cycle) with the minimum total edges length.

26 P1: Minimal Spanning Tree Problem
graph: greedy method geometry(on a plane): divide-and-conquer # of possible spanning trees for n points: nn-2 n=10→108, n=100→10196

27 P1: Minimal Spanning Tree Problem
graph: greedy method geometry(on a plane): divide-and-conquer # of possible spanning trees for n points: nn-2 (Cayley’s theorem) n=10→108, n=100→10196

28 P2: Convex Hull Problem Given a set of 2-dimensional points, find a smallest convex polygon to contain all of these points. Convex Polygon: any line connecting any two points inside the polygon must itself lie inside the polygon.

29 P2: Convex Hull Problem It is not obvious to find a convex hull by examining all possible solutions divide-and-conquer

30 P3: One-Center Problem Given a set of points, find a smallest circle covering all of these points. prune-and-search !!


Download ppt "高等計算機演算法 Advanced Computer Algorithms"

Similar presentations


Ads by Google