# Speed part 6 Barb Ericson Georgia Institute of Technology

```Speed
part 6
Barb Ericson
Georgia Institute of Technology
May 2006
Georgia Institute of Technology
Learning Goals
• Computing Concepts
– Introducing a combinatorial problem
– Introducing the categories of algorithms
• Class P
• Intractable
• Class NP
– Understanding that there are algorithms that
can't be written
– Understanding how to compare computers to
determine which would be faster
Georgia Institute of Technology
Combining Parts
• What if we wanted to create a program
that wrote songs
– By combining musical parts
– leave some out, put some in
– Ignore differences in order (ab = ba)
• How many combinations with 3 parts?
– a, b, c, ab, bc, ac, abc, and empty
• How many combinations with 4 parts?
– a, b, c, d, ab, bc, cd, ac, ad, bd, etc
• Can you find more combinations?
Georgia Institute of Technology
Processing Combinations
• For any n parts there are 2n combinations
– Ignoring order
• What if we had 60 musical bits?
– That is 260 combinations
– 1, 152, 921, 504, 606, 846, 976 combinations
• Imagine we can create each combination
in a single step
– On a 1.5 GHz processor that is 768, 614, 336
seconds or 24 years to execute!
• Processing all combinations is O(2n)
Georgia Institute of Technology
Traveling Salesman Problem
• You have 30 clients to visit
– You want to find the shortest path so that you visit
each one time during a trip
– The best known algorithm for finding the shortest path
is O(n!) (n factorial)
• Factorial of 5 is 5 * 4 * 3 * 2 * 1
• Factorial of 6 is 6 * 5 * 4 * 3 * 2 * 1
• Factorial of n is n * (n – 1) * (n – 2) … to 1
• For 30 cities 30! is
265, 252, 859, 812, 191, 058, 636, 308, 480, 000, 000
– Which wouldn't finish executing in your lifetime!
Georgia Institute of Technology
Problem Classification
• Class P
– Has polynomial running time
• Like linear or binary search
• Intractable
– Problems that we can't solve in a reasonable time
with reasonable data
• Like the combinations of sound parts problem
• Class NP
– Problems that seem intractable, but maybe there is a
solution in Class P that we haven't found yet
• Like the traveling salesman problem
Georgia Institute of Technology
Unsolved Problem in Computer Science
• Is Class NP part of Class P? Or, are they
completely separate?
– If someone finds at least one algorithm to a
Class NP problem that has polynomial
running time
• That would prove NP is part of P
– Or someone has to prove that there is no
algorithm for a class NP problem that can
have a polynomial running time
Georgia Institute of Technology
An Algorithm that can't be Written
• Can a program read another program and the
input to that program and predict if it will ever
stop (halt)?
– This is known as the Halting Problem
– Alan Turing proved that a general algorithm couldn't
be written to cover all possible input
• Using proof by absurdity in 1936
• Before computers were being built!
• For particular programs and input you can write an algorithm
that can tell if it will halt but there is no way to write a general
algorithm that works on any program and input
Georgia Institute of Technology
Comparing Computers
• How would you compare two computer
2.53 GHz Intel
Processor
256 MB SDRAM
80GB Hard Drive
15 inch display
16X CD/DVD
2.7 GHz AMD
Processor
512 MB SDRAM
100 GB Hard Drive
17 inch display
48X CD/DVD
Georgia Institute of Technology
Processor Speed
• 2.53 GHz is about 2.53 billion clock pulses per
second
– This doesn't mean that you can execute 2.53
instructions per second
• Many instructions take more than one clock cycle
• In general, a faster clock pulse means faster
computation
– Especially if the processor type is the same
• How fast do you need?
– It depends on the type of work you are doing
• Word processing can be done on a slow machine
• 3D Game playing improves on a faster processor
Georgia Institute of Technology
Storage
• Fastest and most expensive is cache memory
• Next fastest and next most expensive is RAM or SDRAM
memory
– 256MB is 256 million bytes
– Programs and data must be in RAM during execution
• This memory clears when the computer is off
– Often the best investment is to increase the RAM
• This will make your programs run faster
• The hard drive is the slowest and cheapest memory
– 80GB is 80 billion bytes
– All files are stored on the hard disk
– Getting a bigger hard disk can leave more room for virtual
memory
• Needed when RAM is full (swaps data in and out as needed)
Georgia Institute of Technology
Exercise
• Find the details on at least two different
kinds of computers in use at your school
– Make suggestions for how to improve the
speed of the computers
• Compare at least two computer ads
– Decide which would be best for you to use for
school work
– Decide which would be best for you for
running computer games
Georgia Institute of Technology
Summary
• There are three categories of algorithms
– Class P
• Like binary or linear search
• Can be solved in polynomial time
– Intractable
• Problems that can't be solved in reasonable time with medium to
large amounts of data
• Like combinatorial problems
– Class NP
• Problems that seem intractable but maybe we haven't found the
best algorithm yet
• Like the traveling salesman problem
• Machine speed is based on
– The processor speed
– The amount of each type of memory (cache, RAM, disk)
• Adding RAM is often the cheapest way to improve application speed
Georgia Institute of Technology
```