Question 1

Answer
- The algorithm takes steps. The outer loop for as iterations, and on each iteration it fires another loop for with iterations. At each iteration we compute a product and check an equality, which takes constant time. So overall the algorithm takes steps for some constant , which is same as .
- The algorithm is not a polynomial-time algorithm. While it takes a polynomial number of steps in the value of , it takes an exponential number of steps in the length of , written as a binary string.
Question 2

-
A natural number is composite just if its 1 or if there are with and . So that we can construe a pair as a certificate. Specifically:
- here is an appropriate polynomial bounding whenever .
- is a polynomial-time algorithm that does the following:
- First check that . If not REJECT
- Check that . This is a constant number of comparisons. If one of these checks fails then REJECT
- Check that . This is again a constant number of operations. If so then ACCEPT, else REJECT
-
A language is -complete if and is -hard. A propositional formula is not a tautology just if the assignment with . This is equivalent to saying that there exists an assignment with . In other words, a propositional formula is not a tautology if an only if is satisfiable. From here we show that by a polynomial time reduction from it to SAT. Namely our reduction is given by the function . Now we show that -hard by giving a polynomial-time reduction from SAT to it. For this we chose the reduction .