CS141 Lab 9
Main task for this lab is to
finish the In-lab assignment of Lab 8.
For those studetns who have
finished lab 8, we have bonus questions for you !!
Assignment
Bonus Questions
You can get 1 bonus point if you only show me
your idea of the solution, without finishing your code.
- Find the minimum cost path with less
than K hops. ( 2
bonus points !! )
This is problem does not have a
polynomial time solution. But you can come up with heuristics
methods (approximation algorithms) ie:
* Find
shorstest path, if length < k, then try to improve the cost
(is there another path with less cost? and still less than K hops)
So the
question becomes how can I improve the cost of the current path:
Again
heuristics:
- Remove the most costly (or any) edge of the path and try to
find another path hopefully with less cost.
- To further improve things, after I "replace" an edge try to
replace another edge and so on.
- Stop when I can not replace any edge (including the new ones I
introduced)
Question:
Will this guarantee the best
solution?
Please think of an example if you think that it will
not find the asbolutely best solution.
- Euler cycle ( 2 bonus points !! )
Euler's Problem:
asks whether there is a path through a graph which
traverses each edge only once.
It can be drawn with a single line or there exists a cycle
that passes from every edge exactly once.
The problem can be solved polynomially: given the
starting point you just need to visit all edges.
See: http://ciips.ee.uwa.edu.au/~morris/Year2/PLDS210/hard.html#euler
(only the first part)
Questions:
How to check whether there exists an Euler cycle or not in
a graph, using polynomial running time?
- Suppose the starting point is given
- What you can do if the starting point is not given?