Data Str & Algorithm HW Solutions 95

Data Str & Algorithm HW Solutions 95 - 95 (b) It is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
95 (b) It is possible to compute x n in log n time, and the rest of the formula requires a constant number of multiplications. Thus, the number of multiplications required is polynomial on the input size. 15.5 First, we should note that, for both problems, the decision problem is being considered. TRAVELING SALESMAN is NP -complete if (1) it is in NP , and (2) it is NP -hard. Proving (1) is easy, just provide a non-deterministic polynomial time algorithm. To prove (2), we will reduce to TRAVELING SALESMAN from the known NP -complete problem HAMILTONIAN CYCLE. First, we transform an input to HAMILTONIAN CYCLE into an input to TRAVEL- ING SALESMAN by giving each edge of the input graph an arbitrary dis- tance of 1, and then picking any arbitrary (large) number for the total dis- tance to beat. Then if TRAVELING SALESMAN returns “YES”, we know that there exists a Hamiltonian cycle in the graph since a salesman’s circuit is a Hamiltonian cycle. If TRAVELING SALESMAN returns “NO” then no
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.

Ask a homework question - tutors are online