Download presentation
Presentation is loading. Please wait.
Published byPeregrine Riley Modified over 9 years ago
1
Complexity © 2014 Project Lead The Way, Inc.Computer Science and Software Engineering
2
Constraints: –Limited time to execute –Limited bandwidth –Limited memory to store the program –Limited memory for input/output data These constraints trade off against each other Often readability is more important than any of these Computers Have Finite Resources
3
Time efficiency: How much time does a program take to run? Time complexity of a solution: How much more time will a program take to run if given more bytes as input? How Fast Is a Solution?
4
Time complexity described by the type of curve showing time vs. input bytes Brute force, an algorithm in which you try all possibilities, takes exponentially longer with longer passwords How Fast Is a Solution?
5
Consider passwords with a-z,A-Z,0-9 which allows 26+26+10=62 characters Why Is Brute Force Exponential? bytespasswords to try 162 262 2 362 3 462 4 n62 n
6
Exponential growth will outpace any other kind of growth Make brute force impractical by using long passwords Exponential Curve Gets Ahead of Others
7
Time complexity of a problem is the time complexity of its best solution The algorithm might be quick with special input even if it is long. We describe difficulty using the worst-case input. How Hard Is a Problem?
8
Some problems are so hard the program might never finish. Computable problems can be solved by a computer Analyzing programs is often uncomputable –Halting Theorem: "Will this program ever finish?" is sometimes uncomputable –Security analysis: "Does any input crash this program?" is often uncomputable Computability
9
One-way functions are more time- consuming to undo than to do RSA encryption keys (used for HTTPS) are hard to crack because multiplying is faster than factoring Multiplying big prime numbers is a one- way function Encryption and Time Complexity
10
Linear time complexity: Twice as much input takes twice as much time Time Complexity
11
Quadratic time complexity: –Double the input 4x the time –Triple the input 9x the time Time Complexity
12
Factoring takes longer than quadratic time. So prime numbers can keep our secrets safe... maybe. Encryption Keys Broken by Factoring
13
Feel free to appreciate the beauty without getting into details An Adventure to the Edge of Math
14
One of seven six unsolved Millennium Problems ("Million Dollar Questions") If proved (or disproved), these problems would tell us a lot about what computers can or cannot do –We don't know "how hard" some problems are –Are the hardest "NP problems" (pictured below) solvable in polynomial time? Does P=NP?
15
Time to solve a P problem grows like n some number Time to check an NP problem grows like some number n Does P=NP? The Details
16
If a problem can be checked in reasonable time, can it be solved in reasonable time? NP-Complete problems are the hard ones. They've been shown to be equivalent to each other. Three famous NP-Complete problems with many applications –Travelling Salesperson –Knapsack Problem –3-Color a Graph Does P=NP? We Don't Know!
17
What is the shortest route visiting all these cities? NP-Complete Problems: Travelling Salesperson Problem
18
NP-Complete Problems: Knapsack Problem Choice of items that have weight and value Maximize value without exceeding maximum weight 10 lbs $150 15 lbs $220 3 lbs $40 3 lbs $40 5 lbs $70 3 lbs $40 3 lbs $40 5 lbs $70 5 lbs $70 5 lbs $70
19
Color all nodes using 3 colors total Adjacent nodes must not share color NP-Complete: 3-Color a Graph
20
Another 3-Coloring Problem
21
Can You 3-Color It?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.