This preview shows page 1. Sign up to view the full content.
Unformatted text preview: G is unique). 6. Suppose there is a C++ library on your machine which has the following function: HamC ( G ) : Input: Graph G Output: Yes, if G has a simple cycle which traverses all nodes; No, otherwise. Such a cycle is known as a Hamiltonian Cycle . Let HamC ( G ) implement the above routine. Suppose further, that HamC () runs in polynomial time, that it, it runs in time O ( n c ) for some constant c on an n node graph. A Hamiltonian Path from u to v is a simple path from u to v which traverses all the nodes of a graph. Your mission is to write an algorithm with the following input and output: HamP ( G,u,v ) : Input: Graph G , and nodes u and v in G . Output: Yes, if there is a Hamiltonian Path from u to v in G ; No otherwise. Your algorithm should run in polynomial time. (Hint: You’ll have a tough time doing this without using the HamC () subroutine.)...
View Full Document
This document was uploaded on 12/18/2011.
- Fall '09