Non-Deterministic Polynomial
Time Problems
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
Important Concepts
P: the class of problems with polynomial
(O(nk) solution algorithms
NP: the class of Nondeterministic
Polynomial t
Notes: This is a one-pass editing. If you find some typos, please let me
know. Thanks.
1
Problem 1
Lemma 1. A set S of n points can be formed as a simple polygon if and only
if not all of them are co-linear.
Proof. The only if part is easy to see. The if
Notice: This is a one-pass writing. So if you found any typos, please let me know.
1
Problem 1
1.1
1.1.1
a.
Reduction
Given an instance G = (V, E) of the maximum flow in a network with edge and vertex capacities,
the reduction from it to an instance G = (
Notice: This is a one-pass writing. So if you found any typos, please let me know.
1
Problem 1
The counter-example is as follows:
A1
A2
: 12
: 23
A3
: 34
According to the algorithm given in this problem, if k = 1, then p0 p1 p3 = 8; if k = 2, then
p0 p2 p
Notice: This is a one-pass writing. So if you found any typos, please let me know.
1
Problem 1
1.1
Algorithm Design
To solve this problem, we should have the following observations:
1. In any graph, there are even number of vertices that are of odd degree
Notice: This is a one-pass writing. So if you found any typos, please let me know.
1
Problem 1
Since (a) is a special case of (b), we only present the algorithm for (b).
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
function Closest(S, k)
median
Notice: this is a one-pass writing, so if you found any typos, please let me know. Thanks.
1
Problem 1
We solve this problem by planar sweeping (from left to right) algorithm. On the sweep line, we
maintain a data structure for a set of points L that are
Complexity and Algorithms: Homework-1 solutions
February 5, 2017
Answer 1:
(a) We can solve the problem by the method of guess and verify.
GUESS: T (m, n) = O(m log n)
VERIFY: O(m log n) c m log n
c k log n2 + c (m k) log n2 + a m c m log n
c log n2 (k
Non-Deterministic Polynomial
Time Problems
Bo Liu
Computer Science & Software Engineering
Auburn University
Review on Problem Complexity
Problems
Inherent complexity of problems
Problem Classes: Classifying problems
based on the complexity of the most
Notice: This is a one-pass writing. So if you found any typos, please let me know.
1
Problem 1
1.1
1.1.1
a
Observations
In order to prove that the subgraph-isomorphism problem is N P -complete, we find a problem A
to reduce it to a special case of the sub
CSE 60111, Complexity and Algorithms
Spring Semester, 2017
Assignment 5
Due Date: March 28, 2017 (at the beginning of the CSE 60111 class)
1. Exercise 15-3, page 405 of Cormen, Leiserson, Rivest, and Stein. (20 points)
2. Exercise 15-6, page 408 of Cormen
Chapter 3: Processes
Silberschatz, Galvin and Gagne 2013
Operating System Concepts 9th Edition
Chapter 3: Processes
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication
Examples of IPC Systems
Communication in Client
COMP 3270
Introduction to Algorithms
Homework 2
Due: February 14th, Tuesday by 11:59 PM (midnight)
Please submit as a PDF document using Canvas
Instructions:
1. This is an individual assignment. You should do your own work. Any evidence
of copying will re
COMP 3270
Introduction to Algorithms
Homework 1
Due: January 31st, Tuesday by 11:59 PM (midnight)
Please submit as a PDF document using Canvas
Instructions:
1. This is an individual assignment. You should do your own work. Any evidence of copying
will res
Quiz #4: Solutions
MATH 3710/COMP 3240: Discrete Math/Structures
Friday, October 7, 2016
1. Lemma. Let R = cfw_(p, q)|p, q Z, p + 2q is divisible by 3. Then R is an equivalence relation on Z.
Proof. Let x, y, z Z. We must show that R is reflexive, symmetr
Quiz #6
Name:
MATH 3710 Discrete Math /COMP 3240 Discrete Structures
Friday, April 24, 2015
User id:
Instructions:
This quiz is open notes. You can have any of the following to look at during the quiz: your class notes,
anything youve written yourself, o
1
Problem 1
Let the G(x) = a0 + a1 x + a2 x2 + . . . + an xn + . . . be the generating function
for the sequence cfw_a0 , a1 , . . . , an , . . .. By an = 5an1 6an2 , we get
G(x)
= a0 + a1 x + a2 x2 + a3 x3 + . . . + an xn + . . .
= a0 + a1 x + (5a1 6a0 )
1. What does the recursive algorithm above compute?
A. This recursive algorithm computes the smallest number in the array.
Develop and state the two recurrence relations exactly (i.e., determine all constants)
of this algorithm by following the steps outl
COMP 3270
Homework 3
100 points
Please submit using Canvas by 11:55PM on Tuesday, March 21th, 2017
Instructions:
1. This is an individual assignment. You should do your own work. Any evidence of copying will
result in a zero grade and additional penalties
Dynamic Programming
&
Greedy Algorithm Design
Part I
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
Dynamic programming can be applied to p
roblems whose solution can be recursively c
haracterized, but the corresponding recur
Dynamic Programming
&
Greedy Algorithm Design
Part III
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
Problems for which dynamic programming algo
rithm design will yield correct and efficient algor
ithms
Optimal substructure
Algorithm Complexity/Efficiency
what is efficiency? (two basic types)
why is it important?
Reading Assignment
By now you should have read all of Chapter
1 and Chapter 2 Section 2.1 and Section
2.3.1
How to analyze algorithms
1. How to determine and prov
Techniques for
Detailed Complexity Analysis
of Recursive Algorithms
COMP 7270 N. H Narayanan
Computer Science & Software Engineering
Auburn University
Approximate Big-Oh Analysis of Complexity
Recursive Algorithms
First, understand the recursive algorithm
Problem Classes and
Complexities
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
Problems
Inherent complexity of problems
Problem Classes: Classifying problems
based on the complexity of the most
efficient algorithms to sol
Dynamic Programming
&
Greedy Algorithm Design
Part V
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
Longest Common Subsequence Problem
Example
X = < A, B, C, B, D, A, B >
Y = < B, D, C, A, B, A >
< B, C, A > is a common subs
String Matching
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
String Searching/Matching
Applicable whenever what you are searching for and
where you are searching can both me modeled as
strings from an alphabet
E.g.,
Searchi
An Intro to
Probabilistic Analysis
and
Randomized Algorithms
COMP 7270 N. H Narayanan
Computer Science & Software Engineering
Auburn University
A Hiring Algorithm
HIRE-ASSISTANT(A[1.n] : array of candidates)
1 best=0
2 for i= 1 to n
3 interview candidate
Dynamic Programming
&
Greedy Algorithm Design
Part IV
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
Problem Subgraphs
A systematic approach to deciding lookup
table size and the table filling strategy for t
he iterative DP
Dynamic Programming
&
Greedy Algorithm Design
Part II
N. Hari Narayanan
Computer Science & Software Engineering
Auburn University
The activity-selection problem
The activity-selection problem is to select the ma
ximum number of mutually compatible (i.e.
Let us start with the basics
COMP 7270 N. H Narayanan
Computer Science & Software Engineering
Auburn University
Problems
Problem: A specification of an available input and the
desired output.
Example: Sorting problem
a1 , a2 ,., an
Input: A sequence
The Traveling Salesman Problem
xkcd.com: A webcomic of romance, sarcasm, math and language
Advanced Topics in Algorithms
COMP 7270/7276
Narayanan
COMP 7270 N. H Narayanan
Computer Science & Software Engineering
Auburn University
What this course is all ab
Analyzing algorithm complexi
ty
Assumption: the computer that runs the algorithm
s is a one processor random access machine (RAM)
Analyzing Algorithms
The time needed by an algorithm to solve a problem
depends on the steps of the algorithm that have to