the need for speed. aren’t today’s computers fast enough? justification for better performance...
TRANSCRIPT
The need for speedThe need for speed
Aren’t today’s computers fast enough?Aren’t today’s computers fast enough?
Justification for Better Performance
• complex applications
text graphics video
• real-time applications
• computational science
How do we create faster computation?How do we create faster computation?
1) Faster Hardware
2) Faster Algorithms
How to achieve Moore’s Law?How to achieve Moore’s Law?1)Miniaturization
3) Different technologies
limitations: manufacturing & speed of light
optical computers? biological computers?
2) Multiple processors (supercomputers)
quantum computers?
Algorithm speed can be estimated by counting...the number of instructions executed
...the number of variable/memory assignments...the number of data comparisons
A benchmark is a program execution used to measureexecution time. (a single experimental result)
Benchmarks are one way to analyze algorithms.empirical
approach
analytic
approach
How would youknow which algorithm is
faster?
Counting the CostCounting the CostRecall linear search & binary search
Number of items
Worst Case Expected Case
Number of probes (comparisons)
Linear Binary Linear Binary
1 1 1 1 1
7 7 3 3.5 3
63 63 8 31 8
1000 1000 10 500 10
N N log2N N/2 log2N
Note that 1000 processors could search 1000 items witha single probe per processor.
Algorithm to find the maximum Algorithm to find the maximum Consider 8 numbers.
a b c d e f g h
max of a & b
max of c & d
max of e & f
max of g & h
max of a - d
max of e - h
max of a - h
comparisons
Total number of comparisons?
Algorithm to find the maximum Algorithm to find the maximum What about 7 numbers.
a b c d e f g
max of a & b
max of c & d
max of e & f
max of a - d
max of e - g
max of a - g
Total number of comparisons?
Algorithm to find the maximum Algorithm to find the maximum What about 6 numbers.
a b c d e f
max of a & b
max of c & d
max of e & f
max of a - d
max of a - f
Total number of comparisons?
Algorithm to find the maximum Algorithm to find the maximum
The performance of this algorithm is similarto the linear search.
Number of items Number of comparisons
1 02 16 57 68 7
20 19100 99
N N-1
However, using many processors doesn’t helpas much for the maximum finder algorithm.
Sorting Algorithms Sorting Algorithms Sorting algorithms rearrange items from smallestto largest (or largest to smallest).
One sorting algorithm:- repeatedly find the maximum and move it immediately ahead of all prior maximums.
Example (sort 100 values)Step 1 - find the maximum of 100 values 99 comparisonsStep 2 - find the maximum of 99 values 98 comparisonsStep 3 - find the maximum of 98 values 97 comparisons
• • •Total comparisons for sorting 100: 99+98+97+...+1
Total comparisons for sorting N: (N-1)+(N-2)+(N-3)+...+1= N*(N-1)2
Comparing Algorithm Performance Comparing Algorithm Performance
binary search
linear search
sorting alg
orithm
Are there slower algorithms?Are there slower algorithms?Consider an algorithm to crack your password.One such algorithm attempts every possible keystroke.
AnalysisPassword length Comparisons
1 942 94*94 = 8,8363 94*94*94 = 830,584
8 948 = 6 x 1011
N 94N
... ...
Comparing Algorithm Performance Comparing Algorithm Performance
pas
swo
rd c
rack
er
other algorithms
Functional Growth
1 0 1 94
4 2 16 78074896
8 3 64 6 x 1011
12 3.6 144 (note 1)
16 4 256 (note 2)
20 4.3 400
24 4.6 576
28 4.8 784
32 5 1024
n log2n n2 94n
note 1 - roughly five years of computation for a 1 petaflop supercomputer
note 2 - about 5 times the age of the universe
linear search binary searchsort
password cracker
not practicalfor any largenumber of items
Important ResultsImportant Results#1 -- There are algorithms that take too long to be
practically executed on a computer.
#2 -- These slow algorithms tend of be of the type thatattempt a brute force approach of attemptingall possible combinations.
#3 -- Moore’s Law cannot fix the problem.
So what do we know?So what do we know?Many algorithms can be processed by modern computers.
Some algorithms will be processed with faster computers.
Computers will never be fast enough for some algorithms.