<<

2011‐10‐20

What is an Algorithm [Recall 2010]?

• [Algorith m]: AllA well-orddlltifdered collection of Intro. to the Alg. World unambiguous and effectively computable operations that, when executed, produces a result and halts in a finite amount of time. Yang Wang • You may think Algorithm as abstract computation that is language independent.

Writing It Down [Jeff Ericsion]: Writing It Down [Jeff Ericsion]: • [Pseudo code] uses the structure of formal without understanding why the algorithm programming languages to break algorithms • The syntax is a personal choice, but the into primitive steps. goalil is c lar ity an d prec is ion. • The primitive steps themselves may be written using mathematics, pure English, or a • Any programmer can implement quickly, mixture. works. • Question: Why not Natural Language or Programming Language?

1 2011‐10‐20

Practice

• 1. Give a group of numbers, find the index • Best, Worst and Average Case fthfor the numb bthter that equal ltA?s to A? Easy Hard • Should be: • 2. Give a group of sorted numbers, find – Independent of the specific machine the index for the number that equals to A? – Independent of the detailed implementation – Independent of the input size • Q: Which one is less complex? Q: How?

Complexity Class Optimality

• [Time Optimal] ‐ An algorithm for a given problem is time optimal if its time complexity reaches the lower bound over all the algorithms solving this problem.

• [Objective Optimal]- e.g., minimize the number of money spend

2 2011‐10‐20

Solvability Tractability • [Tractable Problem, P]: a problem that can • Can algorithms solve all problems? . – NO. be solved in ppyolynomial time • [NP]: problems whose positive solutions [Turing halting problem] can be verified in polynomial time. – The problem has the description of a Turing • [NP-Complete]: the most difficult problem machine (Temporary analogy: a computer in NP, a quick algorithm to solve it can be program) as an input. used to solve all other NP problems quickly. – It asks whether this Turing machine will halt (whether the computer program will terminate • [NP-Hard]: at least as hard as the hardest after running for some time, or run forever). problems in NP.

Heroes of Today

• Stephen Cook • One of the seven Millennium Prize Problems selected by the Clay Mathematics Institute to carry a US$ 1,000,000.

• Richard M. Karp

3 2011‐10‐20

Design Pattern Ultimate Dual Goal • • [Greedy Algorithm] I. Ability to analyze an algorithm: – Correct ? • [Divide & Conquer] (with [Recursion]) – Optimal? • [Dynamic Programming] – Complexity? • [Approximation Algorithm] – … • [Heuristic] and [Meta-heuristic] • II. Ability to solve a problem: • [Reduction] (e.g. [ILP], [Network Flow]) – Toolkits

4