0% found this document useful (0 votes)
13 views2 pages

Problem: A. Show That SPATH ? P. B. Show That LPATH Is NP-complete

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
13 views2 pages

Problem: A. Show That SPATH ? P. B. Show That LPATH Is NP-complete

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

Problem

Let G represent an undirected graph. Also let

a. Show that SPATH ? P.

b. Show that LPATH is NP-complete.

Step-by-step solution

Step 1 of 3

a)

Class- P : P is class of languages that are decidable in polynomial time on a deterministic single – tape Turing machine. We have to construct an

deterministic Turing machine to decide SPATH in polynomial time.

Let M be the DTM to decide SPATH in polynomial time.

The algorithm of M is as follows:

”on input where m-node graph G has nodes a and b:

1. Place a mark “o” on node a.

2. for each i from 0 to m:

3. If an edge is found connecting s marked as “i” to an unmarked node t, mark node t with .

4. If b is marked with a value at most k, accept. Otherwise reject.

This algorithm is similar to PATH algorithm. Here we additionally need to keep the track of length of the shortest paths discovered. That will be done in

polynomial time .

Hence, we constructed a DTM M to decide SPATH in polynomial time.

Therefore, .

Comments (1)

Step 2 of 3

(b)

NP - complete: A language B is NP – complete if it satisfies two conditions.

1. B is in NP and

2. Every A in NP is polynomial time reducible to B.

To show LPATH is NP – complete, we need show

1. :

We know that “NP is the class of languages that have polynomial time verifies.
We construct a verifies V for as follows:

”on input , where c is a path:

1. Check c is a non – repeated sequence of nodes in G.

2. Check the first term of c is a and last is b.

3. Check the length of c is larger than or equal to k.

4. If c satisfies the conditions 1 to 3, accept.

5. Otherwise, reject

This verifier V can finish in where is the length of c.

So, .

Comments (1)

Step 3 of 3

2.

Consider an instant of problem where is a graph with assigned starting node a and ending node b.

• The mapping copy and set , then is an instance of .

• It can be finished in polynomial time

• We need to prove

If , then G has a Hamiltonian path from a to b.

• It must be a simple path that goes through every node exactly once,

• Which implies that the length is

• So

If , there exists a simple path from a and b with length .

• Because the graph G only has nodes.

• So this simple path must pass through all of needs in graph G exactly once.

• So this simple path must be a Hamiltonian path.

• It implies that

Therefore, the is NP – complete.

Comment

You might also like