Part 1:
We’re looking to provide a poly-time Turing reduction of the form: , where is the problem of finding a simple path in an undirected graph that visits each vertex. We assume the input is in graph format. That is, a graph where each vertex represents a student, and and edge represents student knows student . We choose an adjacency matrix as the format for storing this graph, where is 1 if student knows student , and 0 otherwise. We want to find a permutation where adjacent students in a row do not know each other. We construct from , where and . In the edges now connect 2 students who do not know each other.
That is, a path that uses every vertex represents a permutation of students, where adjacent students to now know each other → solves this in constant time for us. Assume returns a path in the format of an array. So, we can construct the following pseudocode:
→ Proof of Correctness
- We now argue proof of correctness, that is, the reduction is correct. The algorithm takes the graph as input. In this representation, we have edges between 2 students who know each other. So, we know these 2 students cannot sit beside each other in hallway, How can me model this as path problem?
- We want to formulate this as a path problem, but we do not want to work with a graph where edges represent 2 students knowing each other. Hence, we construct the inverse graph . Now, we have a graph with the same vertices, but now, edges represent 2 students not knowing each other.
- Now, we want to have the 2 endpoints of each edge sitting beside each other, but this is a row, so each student can only have 2 neighbours. This maps very well to finding a path in . For a path in , the edges between represent that knows neither nor . This is the format the permutation output wants to be in. So, for all nodes in this path, they do not know their neighbours in → hence a suitable assignment of students
- If
Ham-Path-Solver(H)
returns an empty array, then this means there is no hamiltonian path in . This tells us, there is no way to configure the students in a row where neighbours do not know each other, which is possible when the number of “knowledges” is too large. Likewise, by returning an array representing a path , this represents a valid assignment of students. As every edge in this path is 2 students who do not know each other. - Hence, this is a correct reduction. To justify it is a polynomial reduction, we show that the run-time on the input-size is polynomial.
→ Runtime
For this problem, we consider the input size to be . Constructing the inverse graph is an operation since we are working with the adjacency-matrix representation (iterate over all rows and columns). We also made the assumption the oracle () runs in constant time. Thus, it is evident the Seating-Plan-Solver
runs in poly-time.
Part 2:
This is false. The class of NP Problems are a family of decision problems. This problem returns a permutation of students, instead of a yes or no solution.
Part 3:
This is false. A problem is NP-Hard does not need to be a decision problem and does not need to be in NP (as answered in the above). Even if we did assume that we had a correct poly-time Turing reduction from to of the form , is not NP-Complete, as it is not a decision problem. Therefore, this does not hold, and given this reduction, we cannot conclude this is NP-Hard.