projetoe análisede algoritmos - puc-riolaber/01intro.pdf · projetoe análisede algoritmos prof....
TRANSCRIPT
![Page 2: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/2.jpg)
Introduction
Jeff Edmonds
York University
LectureLecture 11
•So you want to be a computer scientist?
•Grade School Revisited: How To Multiply Two Numbers
![Page 3: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/3.jpg)
So you want to be a computer
scientist?
![Page 4: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/4.jpg)
Is your goal to be
a mundane programmer?
![Page 5: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/5.jpg)
Or a great leader and thinker?
![Page 6: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/6.jpg)
Original Thinking
![Page 7: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/7.jpg)
Boss assigns task:
– Given today’s prices of pork, grain, sawdust, …
– Given constraints on what constitutes a hotdog.
– Make the cheapest hotdog.
Everyday industry asks these questions.
![Page 8: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/8.jpg)
• Um? Tell me what to code.
With more suffocated software engineering systems,
the demand for mundane programmers will diminish.
Your answer:
![Page 9: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/9.jpg)
Your answer:
• I learned this great algorithm that will work.
Soon all known algorithms
will be available in libraries.
![Page 10: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/10.jpg)
Your answer:
• I can develop a new algorithm for you.
Great thinkers
will always be needed.
![Page 11: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/11.jpg)
– Content: An up to date grasp of fundamental
problems and solutions
– Method: Principles and techniques to solve the
vast array of unfamiliar problems that arise in a
rapidly changing field
The future belongs to the
computer scientist who has
Rudich www.discretemath.com
![Page 12: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/12.jpg)
Course Content
• A list of algoirthms.
– Learn their code.
– Trace them until you are convenced that they
work.
– Impliment them.class InsertionSortAlgorithm extends SortAlgorithm
{
void sort(int a[]) throws Exception {
for (int i = 1; i < a.length; i++) {
int j = i;
int B = a[i];
while ((j > 0) && (a[j-1] > B)) {
a[j] = a[j-1];
j--; }
a[j] = B;
}}
![Page 13: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/13.jpg)
Course Content• A survey of algorithmic design techniques.
• Abstract thinking.
• How to develop new algorithms for any problem that may arise.
![Page 14: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/14.jpg)
Study:
• Many experienced programmers were asked
to code up binary search.
![Page 15: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/15.jpg)
Study:
• Many experienced programmers were asked
to code up binary search.
80% got it wrong
Good thing is was not for a
nuclear power plant.
![Page 16: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/16.jpg)
What did they lack?
![Page 17: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/17.jpg)
What did they lack?
• Formal proof methods?
![Page 18: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/18.jpg)
What did they lack?
• Formal proof methods?
Yes, likely
Industry is starting to
realize that formal methods
are important.
But even without formal
methods …. ?
![Page 19: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/19.jpg)
What did they lack?
• Fundamental understanding of the
algorithmic design techniques.
• Abstract thinking.
![Page 20: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/20.jpg)
Course Content
Notations, analogies, and abstractions
for developing,
thinking about,
and describing algorithms
so correctness is transparent
![Page 21: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/21.jpg)
Please feel free to ask questions!
![Page 22: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/22.jpg)
A survey of fundamental
ideas and algorithmic
design techniques
For example . . .
![Page 23: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/23.jpg)
Start With Some Math
Input Size
Time
Classifying Functions
f(i) = nΘ(n)
Recurrence Relations
T(n) = a T(n/b) + f(n)
Time Complexityt(n) = Θ(n2)
![Page 24: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/24.jpg)
Graph Search Algorithms
![Page 25: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/25.jpg)
Greedy Algorithms
![Page 26: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/26.jpg)
Recursive Algorithms
?
?
![Page 27: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/27.jpg)
Dynamic Programing
![Page 28: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/28.jpg)
Network Flows
![Page 29: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/29.jpg)
Reduction
=
Rudich www.discretemath.com
![Page 30: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/30.jpg)
Useful Learning Techniques
![Page 31: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/31.jpg)
Read Ahead
You are expected to read the lecture notes
before the lecture.
This will facilitate more productive discussion
during class.
![Page 32: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/32.jpg)
Be Creative
•Ask questions.
• Why is it done this way and not that way?
![Page 33: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/33.jpg)
Guesses and Counter Examples
• Guess at potential algorithms for solving a
problem.
• Look for input instances for which your
algorithm gives the wrong answer.
![Page 34: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/34.jpg)
Refinement:
The best solution comes from a
process of repeatedly refining and
inventing alternative solutions
Rudich www.discretemath.com
![Page 35: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/35.jpg)
Grade School Revisited:How To Multiply Two Numbers
2 X 2 = 5
A Few Example AlgorithmsA Few Example Algorithms
Rudich www.discretemath.com
![Page 36: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/36.jpg)
Slides in this next section
produced by
Steven Rudich
from Carnegie Mellon University
Rudich www.discretemath.com
Individual Slides
will be marked
![Page 37: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/37.jpg)
Complex Numbers•Remember how to multiply 2 complex numbers?
•(a+bi)(c+di) = [ac –bd] + [ad + bc] i
•Input: a,b,c,d Output: ac-bd, ad+bc
•If a real multiplication costs $1 and an addition cost a penny. What is the cheapest way to obtain the output from the input?
•Can you do better than $4.02?
![Page 38: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/38.jpg)
Gauss’ $3.05 Method:
Input: a,b,c,d Output: ac-bd, ad+bc
• m1 = ac
• m2 = bd
• A1 = m1 – m2 = ac-bd
• m3 = (a+b)(c+d) = ac + ad + bc + bd
• A2 = m3 – m1 – m2 = ad+bc
![Page 39: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/39.jpg)
Question:•The Gauss “hack” saves one multiplication
out of four. It requires 25% less work.
•Could there be a context where
performing 3 multiplications for every 4
provides a more dramatic savings?
![Page 40: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/40.jpg)
Odette Bonzo
![Page 41: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/41.jpg)
How to add 2 n-bit numbers.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*+
![Page 42: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/42.jpg)
How to add 2 n-bit numbers.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*+
![Page 43: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/43.jpg)
How to add 2 n-bit numbers.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*+
![Page 44: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/44.jpg)
How to add 2 n-bit numbers.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*+
![Page 45: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/45.jpg)
How to add 2 n-bit numbers.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*+
![Page 46: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/46.jpg)
How to add 2 n-bit numbers.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
+
*
*
![Page 47: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/47.jpg)
Time complexity of
grade school addition
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
+*
*
*
*
*
*
T(n) = The amount of
time grade school
addition uses to add
two n-bit numbers
= θ(n) = linear time.
On any reasonable
computer adding 3
bits can be done in
constant time.
![Page 48: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/48.jpg)
# of bits in numbers
t
i
m
e
f = θ(n) means that f can be sandwiched between two lines
![Page 49: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/49.jpg)
Please feel free to ask questions!
Rudich www.discretemath.com
![Page 50: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/50.jpg)
Is there a faster way to add?
• QUESTION: Is there an algorithm to add
two n-bit numbers whose time grows sub-
linearly in n?
![Page 51: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/51.jpg)
Any algorithm for addition must
read all of the input bits– Suppose there is a mystery algorithm that does not examine each bit
– Give the algorithm a pair of numbers. There must be some unexamined bit position i in one of the numbers
– If the algorithm is not correct on the numbers, we found a bug
– If the algorithm is correct, flip the bit at position i and give the algorithm the new pair of numbers. It give the same answer as before so it must be wrong since the sum has changed
![Page 52: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/52.jpg)
So any algorithm for addition must use
time at least linear in the size of the
numbers.
Grade school addition is essentially as
good as it can be.
![Page 53: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/53.jpg)
How to multiply 2 n-bit numbers.
X* * * * * * * * * * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * * * * * * * * * *
n2
![Page 54: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/54.jpg)
How to multiply 2 nHow to multiply 2 n--bit numbers.bit numbers.
X* * * * * * * * * * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * ** * * * * * * *
* * * * * * * * * * * * * * * *
n2
I get it! The total time
is bounded by cn2.
![Page 55: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/55.jpg)
Grade School Addition: Linear time
Grade School Multiplication: Quadratic time
•No matter how dramatic the difference in the constants the quadratic curve will eventually
dominate the linear curve
# of bits in numbers
t
i
m
e
![Page 56: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/56.jpg)
Neat! We have demonstrated that as
things scale multiplication is a harder
problem than addition.
Mathematical confirmation of our
common sense.
![Page 57: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/57.jpg)
Don’t jump to conclusions!
We have argued that grade school
multiplication uses more time than
grade school addition. This is a
comparison of the complexity of two
algorithms.
To argue that multiplication is an
inherently harder problem than
addition we would have to show that
no possible multiplication algorithm
runs in linear time.
![Page 58: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/58.jpg)
Grade School Addition: θ(n) time
Grade School Multiplication: θ(n2) time
Is there a clever algorithm to
multiply two numbers in linear
time?
![Page 59: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/59.jpg)
Despite years of research, no one
knows! If you resolve this question, PUC
will give you a PhD!
![Page 60: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/60.jpg)
Is there a faster way to
multiply two numbers than the
way you learned in grade
school?
![Page 61: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/61.jpg)
Divide And Conquer
(an approach to faster algorithms)
•DIVIDE a problem into smaller
subproblems
•CONQUER them recursively
•GLUE the answers together so as to obtain
the answer to the larger problem
![Page 62: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/62.jpg)
Multiplication of 2 n-bit numbers• X =
• Y =
• X = a 2n/2 + b Y = c 2n/2 + d
• XY = ac 2n + (ad+bc) 2n/2 + bd
a b
c d
![Page 63: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/63.jpg)
Multiplication of 2 n-bit numbers
• X =
• Y =
• XY = ac 2n + (ad+bc) 2n/2 + bd
a b
c d
MULT(X,Y):
If |X| = |Y| = 1 then RETURN XY
Break X into a;b and Y into c;d
RETURN
MULT(a,c) 2n + (MULT(a,d) + MULT(b,c)) 2n/2 + MULT(b,d)
![Page 64: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/64.jpg)
Time required by MULT
• T(n) = time taken by MULT on two n-bit
numbers
• What is T(n)?
What is its growth rate?
Is it θ(n2)?
![Page 65: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/65.jpg)
Recurrence Relation
•T(1) = k for some constant k
•T(n) = 4 T(n/2) + k’ n + k’’ for some constants k’ and k’’
MULT(X,Y):
If |X| = |Y| = 1 then RETURN XY
Break X into a;b and Y into c;d
RETURN
MULT(a,c) 2n + (MULT(a,d) + MULT(b,c)) 2n/2 + MULT(b,d)
![Page 66: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/66.jpg)
Let’s be concrete
•T(1) = 1
•T(n) = 4 T(n/2) + n
•How do we unravel T(n) so that we can
determine its growth rate?
![Page 67: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/67.jpg)
Technique 1
Guess and Verify
•Recurrence Relation:
T(1) = 1 & T(n) = 4T(n/2) + n
•Guess: G(n) = 2n2 – n
•Verify: Right Hand SideLeft Hand Side
1
4T(n/2) + n
= 4 [2(n/2)2 – (n/2)] + n
= 2n2 – n
T(1) = 2(1)2 – 1
T(n)
= 2n2 – n
![Page 68: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/68.jpg)
Technique 2: Decorate The Tree
• T(n) = n + 4 T(n/2)
n
T(n/2) T(n/2) T(n/2) T(n/2)
T(n) =
• T(n) = n + 4 T(n/2)
n
T(n/2) T(n/2) T(n/2) T(n/2)
T(n) =
T(1)
•T(1) = 1
1=
![Page 69: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/69.jpg)
n
T(n/2) T(n/2) T(n/2) T(n/2)
T(n) =
![Page 70: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/70.jpg)
n
T(n/2) T(n/2) T(n/2)
T(n) =
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
![Page 71: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/71.jpg)
nT(n) =
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
![Page 72: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/72.jpg)
nT(n) =
n/2 n/2 n/2n/2
11111111111111111111111111111111 . . . . . . 111111111111111111111111111111111
n/4 n/4 n/4n/4n/4n/4n/4n/4n/4n/4n/4n/4n/4n/4n/4 n/4
![Page 73: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/73.jpg)
Level i is the sum of 4i copies of n/2i
1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
. . . . . . . . . . . . . . . . . . . . . . . . . .
n/2 + n/2 + n/2 + n/2
n
n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4
0
1
2
i
log n2
![Page 74: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/74.jpg)
Level i is the sum of 4i copies of n/2i
1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
. . . . . . . . . . . . . . . . . . . . . . . . . .
n/2 + n/2 + n/2 + n/2
n
n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4
0
1
2
i
log n2
=1⋅n
= 4⋅n/2
= 16⋅n/4
= 4i ⋅n/2i
Total: θ(nlog4) = θ(n2)
= 4logn⋅n/2logn
=nlog4⋅1
![Page 75: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/75.jpg)
Divide and Conquer MULT: θ(n2) time
Grade School Multiplication: θ(n2) time
All that work for nothing!
![Page 76: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/76.jpg)
MULT revisited
• MULT calls itself 4 times. Can
you see a way to reduce the
number of calls?
MULT(X,Y):
If |X| = |Y| = 1 then RETURN XY
Break X into a;b and Y into c;d
RETURN
MULT(a,c) 2n + (MULT(a,d) + MULT(b,c)) 2n/2 + MULT(b,d)
![Page 77: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/77.jpg)
Gauss’ Hack:
Input: a,b,c,d Output: ac, ad+bc, bd
• A1 = ac
• A3 = bd
• m3 = (a+b)(c+d) = ac + ad + bc + bd
• A2 = m3 – A1- A3 = ad + bc
![Page 78: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/78.jpg)
Gaussified MULT
(Karatsuba 1962)
•T(n) = 3 T(n/2) + n
•Actually: T(n) = 2 T(n/2) + T(n/2 + 1) + kn
MULT(X,Y):
If |X| = |Y| = 1 then RETURN XY
Break X into a;b and Y into c;d
e = MULT(a,c) and f =MULT(b,d)
RETURN e2n + (MULT(a+b, c+d) – e - f) 2n/2 + f
![Page 79: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/79.jpg)
nT(n) =
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)T(n/4)
![Page 80: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/80.jpg)
n
T(n/2) T(n/2) T(n/2)
T(n) =
![Page 81: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/81.jpg)
n
T(n/2) T(n/2)
T(n) =
n/2
T(n/4)T(n/4)T(n/4)
![Page 82: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/82.jpg)
nT(n) =
n/2
T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)
n/2
T(n/4)T(n/4)T(n/4)
![Page 83: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/83.jpg)
Level i is the sum of 3i copies of n/2i
1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
. . . . . . . . . . . . . . . . . . . . . . . . . .
n/2 + n/2 + n/2
n
n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4
0
1
2
i
log n2
![Page 84: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/84.jpg)
=1⋅n
= 3⋅n/2
= 9⋅n/4
= 3i ⋅n/2i
Total: θ(nlog3) = θ(n1.58..)
Level i is the sum of 3i copies of n/2i
1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
. . . . . . . . . . . . . . . . . . . . . . . . . .
n/2 + n/2 + n/2
n
n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4
0
1
2
i
log n2 = 3logn⋅n/2logn
=nlog3⋅1
![Page 85: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/85.jpg)
Dramatic improvement for large n
Not just a 25% savings!
θ(n2) vs θ(n1.58..)
![Page 86: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/86.jpg)
Multiplication Algorithms
n logn loglognFastest Known
n1.58…Karatsuba
n2Grade School
![Page 87: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/87.jpg)
You’re cool! Are you free sometime
this weekend?
Not interested, Bonzo.
I took the initiative and asked
out a guy in my
Databases class.
![Page 88: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/88.jpg)
End
![Page 89: Projetoe Análisede Algoritmos - PUC-Riolaber/01intro.pdf · Projetoe Análisede Algoritmos Prof. Eduardo Laber laber laber@inf.puc-rio.br. Introduction Jeff Edmonds York University](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec386bd59577c71ea47842b/html5/thumbnails/89.jpg)
Informações
Livro Texto: Algorithms Design
Eva Tardos and Jon Kleinberg
www-di/inf.puc-rio.br/~laber