This preview shows pages 1–2. Sign up to view the full content.
Lecture Notes
CMSC 251
HC to HP Reduction
bool HamCycle(graph G) {
for each edge {u,v} in G {
copy G to a new graph G’
delete edge {u,v} from G’
add new vertices x and y to G’
add new edges {x,u} and {y,v} to G’
if (HamPath(G’)) return true
}
return false
// failed for every edge
}
This is a rather inefﬁcient reduction, but it does work. In particular it makes
O
(
e
)
calls to the
Ham
Path()
procedure. Can you see how to do it with fewer calls? (Hint: Consider applying this to the
edges coming out of just one vertex.) Can you see how to do it with only one call? (Hint: This is
trickier.)
As before, notice that we didn’t really attempt to solve either problem. We just tried to ﬁgure out how
to make a procedure for one problem (Hamiltonian path) work to solve another problem (Hamiltonian
cycle). Since HC is NPcomplete, this means that there is not likely to be an efﬁcient solution to HP
either.
Lecture 29: Final Review
(Tuesday, May 12, 1998)
Final exam:
As mentioned before, the exam will be comprehensive, but it will stress material since the
second midterm exam. I would estimate that about 50–70% of the exam will cover material since the
last midterm, and the remainder will be comprehensive. The exam will be closed book/closed notes
with three sheets of notes (front and back).
Overview:
This semester we have discussed general approaches to algorithm design. The goal of this course
is to improve your skills in designing good programs, especially on complex problems, where it is not
obvious how to design a good solution. Finding good computational solutions to problems involves
many skills. Here we have focused on the higher level aspects of the problem: what approaches to use
in designing good algorithms, how generate a rough sketch the efﬁciency of your algorithm (through
asymptotic analysis), how to focus on the essential mathematical aspects of the problem, and strip away
the complicating elements (such as data representations, I/O, etc.)
Of course, to be a complete programmer, you need to be able to orchestrate all of these elements. The
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '11
 Staff

Click to edit the document details