270 likes | 286 Views
Chapter 1 -- Introduction Chapter 2 -- Algorithms and Complexity. 暨南大學資訊工程系 黃光璿 (Guan-Shieng Huang) 2005/02/21. A Rock Game. Alice vs Bob 10+10 Bob can solve 2+2. How about 20+20? Or, 10+10+10? The rule is: you can remove one rock from each pile or both of them.
E N D
Chapter 1 -- IntroductionChapter 2 -- Algorithms and Complexity 暨南大學資訊工程系 黃光璿 (Guan-Shieng Huang) 2005/02/21
A Rock Game • Alice vs Bob • 10+10 • Bob can solve 2+2. • How about 20+20? Or, 10+10+10? • The rule is: you can remove one rock from each pile or both of them. • The player who takes the last rock(s) wins the game.
Alice • Move first. • Had learned Algorithm CSIE210022.
Answer • If you had learned Finite Automata…
What is an Algorithm? • Assignment • a:=1 • b:=a
Arithmetic • a+b • a-b • (a+b)*c+a/d
Conditional • if statement1 then statement2else statement3
for loops • for i=1 to 100 do statement
while loops • while statement1 dostatement2
Array access • a[100] • a[a[i]]
Biological Algorithms vs Computer Algorithms DNA DNA helicase topoisomerase single-strandbinding protein
primase DNA polymerase 5’ 3’
Correct versus Incorrect Algorithms • Soundness • 所考慮到的情況都正確的處理 • Completeness • 考慮到所有可能的情況
Recursive Algorithms • Tower of Hanoi Problem
Big-O Notation • A function f(x) is O(g(x)) if there are positive real constants c and x0 such that f(x)≤g(x) for all values of x≧x0.
Algorithm Design Techniques • Exhaustive Search • Branch-and-Bound Algorithms • Dynamic Programming • Divide-and-Conquer Algorithms • Machine Learning • Randomized Algorithms
Tractable versus Intractable Problems • polynomial-time solvable problems • nondeterministic polynomial-time solvable problems • beyond P • P vs NP