# Lecture # 38 Algorithms & Problem Solving: How Hard Can it Get?

## Presentation on theme: "Lecture # 38 Algorithms & Problem Solving: How Hard Can it Get?"— Presentation transcript:

Lecture # 38 Algorithms & Problem Solving: How Hard Can it Get?

Computability Tractable problems (P): Can be solved by a a computer is some deterministic (reasonable) polynomial time –What is a ”reasonable” running time? Intractable problems (NP): 1. Guess the solution 2. Answer must be verifiable in polynomial time

Goal: transfer all n disks from peg 1 to peg 3 Rules: –move one disk at a time –never place a larger disk on top of a smaller one Example: Towers of Hanoi Simonas Šaltenis, Aalborg University, simas@cs.auc.dk 1 2 3

DEMO (http://www.mathcs.org/java/programs/Hanoi/index.html) Towers of Hanoi

How Long? 64 disks Move 1 disk per second 585 billion years Is that tractable/reasonable? Towers of Hanoi

Monkey Puzzle Nine square cards with imprinted “monkey halves” Goal: arrange the cards in 3x3 square with matching halves... Simonas Šaltenis, Aalborg University, simas@cs.auc.dk

More Monkeying around How long to match the monkey cards for a 3x3 square? Trying all possibilities, if you could try 1/per second, you could do it in about 4 days How long to match the monkey cards for a 5x5 square? Trying all possibilities, if you could try 1,000,000/per second, it would take 490 billion years to verify whether a solution exists Simonas Šaltenis, Aalborg University, simas@cs.auc.dk

Monkey Business cont. Can we improve the Brute Force algorithm? A smart algorithm would still take thousands of years, worst case Easier way to find solutions? MAYBE! But nobody has found them, yet! (room for smart students...) Simonas Šaltenis, Aalborg University, simas@cs.auc.dk

Reasonable vs. Unreasonable function/ n 102050100300 n2n2 1/10,000 second 1/2,500 second 1/400 second 1/100 second 9/100 second n5n5 1/10 second 3.2 seconds 5.2 minutes 2.8 hours 28.1 days 2n2n 1/1000 second 1 second 35.7 years 400 trillion centuries a 75 digit- number of centuries n 2.8 hours 3.3 trillion years a 70 digit- number of centuries a 185 digit- number of centuries a 728 digit- number of centuries Exponential Polynomial Simonas Šaltenis, Aalborg University, simas@cs.auc.dk How Hard can a Problem Be?:

Reasonable vs. Unreasonable ”Good”, reasonable algorithms –algorithms bound by a polynomial function n k –Tractable problems ”Bad”, unreasonable algorithms –algorithms whose running time is above n k –Intractable problems intractable problems tractable problems Problems with no reasonable algorithms/solutions Problems with reasonable (polynomial-time) algorithms/solutions Simonas Šaltenis, Aalborg University, simas@cs.auc.dk

So What?! Computers get faster every year –But that is an insignificant speed-up (a constant) compared to exponential running time Maybe the Monkey puzzle is just one specific problem, we could simply ignore –the monkey puzzle falls into a category of problems called NPC (NP complete) problems (~1000 problems) –all have unreasonable solutions –not known to admit reasonable ones… Simonas Šaltenis, Aalborg University, simas@cs.auc.dk

Download ppt "Lecture # 38 Algorithms & Problem Solving: How Hard Can it Get?"

Similar presentations