You are on page 1of 61

Apex Institute of Technology

Department of Computer Science & Engineering


Bachelor of Engineering (Computer Science & Engineering)
Design and Analysis of Algorithms– (20CST-282)
Prepared By: Dr. Vipin Tiwari (E10753)

05/20/2022 DISCOVER . LEARN . EMPOWER


1
The Round Table Problem
Sir Percivale

Sir Lancelot
Sir Galahad Sir Gareth
Sir Bevidere Sir Pericvale
The Round Table Problem
Map Coloring
5 Colors
All Maps are Four Colorable
Can we use only 3 colors?
Sudoku
Sudoku
All The Same Problem

Solve one of these problems, you solve them all.


And Thousands More…
• Bin
Minesweeper
Packing
• Job
Traveling
Scheduling
Salesperson
• Filling
Cliquesa Knapsack
• Crossword
Integer Programming
Puzzle Construction
• Code
Quadratic
Generation
Programming
• Sequencing
Maximum Cut DNA
• Finding
Longest Arbitrage
Path
Can We Solve These Problems?

P = NP?
The P versus NP Question
• P – Efficiently Computable Solutions
• NP – Efficiently Verifiable Solutions
P – Efficiently Computable
• Finding the shortest path from
point A to point B
NP – Efficiently Verifiable
NP – Efficiently Verifiable
NP-Complete
NPC

NP

P
If P ≠ NP
NPC

NP

P
If P = NP

NPC
NP

P
P versus NP
• General Consensus: P ≠ NP
• Major Open Problem: Formally prove P ≠ NP
• First to do so wins $1,000,000
• One of the seven “Millennium” Problems of the Clay Mathematics
Institute.
• Many approaches, all have failed miserably.
P versus NP: A Short History

• 1936: Alan Turing tries to understand how a mathematician thinks and


developed a theoretical model of computation we now call the Turing
Machine.
P versus NP: A Short History
• 1956: The logician Kurt Gödel, in a letter to John van Neumann, asked
a question mathematically equivalent to P = NP?
• The letter was never followed up and soon forgotten.
P versus NP: A Short History
• 1962: Juris Hartmanis and Richard Stearns develop the notion of
“Computational Complexity” by suggesting we look at the time a
program takes as a function of the size of the input.
• They show that given more time, a computer can do solve more
problems.
P versus NP: A Short History
• 1965: Independently Alan Cobham and Jack Edmonds suggest that
one can characterize efficient computation by having the running time
run in some fixed polynomial of the input length.
• This class of problems is later given the name P.
P versus NP: A Short History
• 1972: Steve Cook gave the first NP-complete problem, Boolean
Formula Satisfiability, and formally defined the P versus NP problem.

u  v  w   u  w  x    v  w  x 
P versus NP: A Short History
• 1973: Richard Karp showed that several natural problems, such as
Clique and Traveling Salesperson are NP-complete.
• The rest is history.
Suppose P = NP
• What a beautiful world…
We Can Efficiently Solve
• Bin
Minesweeper
Packing
• Job
Traveling
Scheduling
Salesperson
• Filling
Cliquesa Knapsack
• Crossword
Integer Programming
Puzzle Construction
• Code
Quadratic
Generation
Programming
• Sequencing
Maximum Cut DNA
• Finding
Longest Arbitrage
Path
Occam’s Razor
• William of Ockham
• Entities should not be multiplied
beyond necessity.
• The shortest explanation of the
data is the best one.
Translation
• In
Imthe
Anfang
beginning
schuf Gott
God created
die Himmelthe heavens
und die Erde.
and the
Undearth.
die Erde
Now war
thewüst
earth
und
wasleer,
formless
und Finsternis
and empty,
darkness
war über was
der Tiefe;
over the
undsurface
der Geist
of the
Gottes
deep,
schwebte
and theüber
Spiritden
of God
Wassern.
was hovering
Und Gottover
sprach:
the waters.
Es werde
And God
Licht! Undsaid,
es wurde
"Let there
Licht.beUnd
light,"
Gottand
sahthere
das Licht,
was light.
daß esGod
gutsaw
war;that
undthe
Gott
light
schied
was good,
das Licht
andvon
He
separated
der Finsternis.
the light
Und from
Gott nannte
the darkness.
das Licht
God
Tag,
called
undthe
die light
Finsternis
"day,"nannte
and theerdarkness
Nacht. Und
he called
es wurde
"night."und
Abend, Andesthere
wurdewasMorgen:
evening,einandTag.
there was morning—the first day.
Translation
• Imthe
In Anfang
beginning
schuf Gott
God created
die Himmel
the heavens
und die Erde.
and the
Undearth.
die Erde
Now warthewüst
earth
und
was
leer,
formless
und Finsternis
and empty,
wardarkness
über derwas
Tiefe;
over
und
the
der
surface
Geist Gottes
of the deep,
schwebte
and über
the Spirit
den of God
was hovering
Wassern. Undover
Gottthe
sprach:
waters.
Es werde
And GodLicht!
said,
Und
"Let
esthere
wurdebeLicht.
light,"
Und
andGott
there
sahwas
daslight.
Licht,God
daßsaw
es gut
thatwar;
the und
lightGott
was schied
good, and
das He
Licht
separated
von der Finsternis.
the light from
Undthe
Gott
darkness.
nannte dasGod
Licht
called
Tag, the
undlight
die Finsternis
"day," andnannte
the darkness
er Nacht.
he Und
called
es"night."
wurde Abend,
And there
undwas
es wurde
evening,
Morgen:
and there
ein Tag.
was morning—the first day.
If P = NP…
• Can efficiently find the smallest program to translate documents.
• Recognizing Faces
• Speech to Text, Pictures to Text
• Recognizing Music
•…
No Such Luck
• Life can’t be so good so we all
believe
P ≠ NP.
• Once we show a problem is “NP-
Complete” we should stop looking
for an efficient algorithm.
What to do about hard problems?
• Solve it anyway.
• Computers are very fast these days.
• Heuristics.
• Your specific instance might not be that hard.
• Approximation.
• Can’t get best algorithm but perhaps one can get a “good enough” solution.
Solve It Anyway
• There are about 2x1075 possible
numbers to try.
• A simple backtracking algorithm
can solve the problem on a PC in a
few seconds.
Heuristics
• Most puzzles are designed to be
solved by humans.
Approximation
Clique Problem
• Find a large group of people all of
whom are friends with each other.
• Coming up with a clique anywhere
close to the largest clique is as hard
as solving NP-complete problems.
Good News with Hard Problems
• Pseudorandom Generators
• Hard functions can help us create fake random coins that are as good as real
random coins.
• Public-Key Cryptography
Public-Key Cryptography
Impossible if P = NP
Possible if Factoring is Hard
NP as Proof System
NP as Proof System
Zero-Knowledge Proof System
• Can convince someone that a
solution exists without revealing
any details of the solution.
• Requires cryptography and
verification process is randomized.
Interactive Proofs
► Can convince someone there is no
solution.
► Verification process is randomized.

5
Proof Checking
Probabilistically Checkable Proof
• There is a proof that a solution
exists where we need to only see
three randomly chosen bits of the
proof.
• This is the tool that shows that
Clique is hard to approximate.
Quantum Computing
Quantum Bits
Entanglement
Interference

• Use entanglement to search many states.


• Use interference to eliminate the ones that don’t solve your problem.
Shor’s Algorithm
• Factor quickly with a quantum computer.
Complexity of Factoring
NPC

NP

P
Complexity of Quantum
NPC

NP
Quantum

P
Grover’s Algorithm
• Search a trillion pieces of hay to
find the needle by making only a
million quantum hay searches.
• Can be used to give quadratic
improvement to solving NP
problems.
References
• Fundamentals of Computer Algorithms 2nd Edition (2008) by Horowitz, Sahni
and Rajasekaran
• Introduction to Algorithms 3rd Edition (2012) by Thomas H Cormen, Charles E
Lieserson, Ronald

60
THANK YOU

For queries
Email: vipin.e10753@cumail.in

05/20/2022 61

You might also like