Lecture 6 - NP Intro Flashcards
What is an eulerian cycle?
A cycle that traverses each edge exactly once.
When does a graph have a eulerian cycle?
When each vertex has an even degree (edge to enter and edge to leave)
What is the complexity of eulerian cycle?
O(m+n) with adjacency list
O(m^2) with adjacency matrix
What is a hamiltonian cycle?
cycle that visits each vertex exactly once
What is poly time?
O(n^c), anything better than exponentia l and factorial time
What is the time complexity of the brute force solution of hamiltonian cycle?
O(n!) as we can have n! permutations (possible paths). For permutation we also have to check whether the path is a hamiltonian cycle, this is O(n^2)
TOTAL IS O(n!n^2)
Brute force approach for hamiltonian cycle is more efficient when…
using an adjacency matrix. It requires O(n) to check whether an edge exists. We have to check whether a value exists in the array.
When does the distinction between the runtime of algorithms become dramatic?
Between poly-time and exponential time.
O(n^c) -> O(x^n)
This applies even if we increase computing power
What algorithms are bad in general?
Exponential time or worse
What algorithms are good in generaL
Polynomial time
These are ‘efficient’ algorithms
When is a problem poly time solvable?
When it has a poly-time algorithm.
What does it mean when a problem is intractable?
There doesn’t exist a poly-time solution for the problem
What can we try and prove?
That a problem is intractable or the problem is just as hard as a family of other difficult problems
What are these other difficult problems in one family?
Np-complete problems
State of the hamiltonian cycle problem:
- no poly-time algorithm
- no proof of intractability
- known as a NP-COMPLETE problem