a) If you observe carefully, P is always a subset of NP. Now, P = NP if and only if we can design an algorithm that solves any given instance of problem in NP in polynomial time.
Clearly, none of your friends have found a way to solve ProblemA in polynomial time. And, hence they have not yet proved that P = NP.
b) The time complexity of this algorithm is always O(n) and hence, TRIANGLENUMBER is a plynomial time algorithm.
Question 4 (4 marks). a. Consider the decision problems PROBLEMA and PROBLEMB. PROBLEMA is known to...
algorithm TRUE OR FALSE TRUE OR FALSE Optimal substructure applies to alloptimization problems. TRUE OR FALSE For the same problem, there might be different greedy algorithms each optimizes a different measure on its way to a solutions. TRUE OR FALSE Computing the nth Fibonacci number using dynamic programming with bottom-upiterations takes O(n) while it takes O(n2) to compute it using the top-down approach. TRUE OR FALSE Every computational problem on input size n can be...
3. (3 pts) Two well-known NP-complete problems are 3-SAT and TSP, the traveling salesman problem. The 2-SAT problem is a SAT variant in which each clause contains at most two literals. 2-SAT is known to have a polynomial-time algorithm. Is each of the following statements true or false? Justify your answer. a. 3-SAT sp TSP. b. If P NP, then 3-SAT Sp 2-SAT. C. If P NP, then no NP-complete problem can be solved in polynomial time.
Please answer this in python pseudocode. It's an algorithm question. 1. [10 marks] Consider the function SumKSmallest(A[0..n – 1), k) that returns the sum of the k smallest elements in an unsorted integer array A of size n. For example, given the array A=[6,-6,3,2,1,2,0,4,3,5] and k=3, the function should return -5. a. [3 marks) Write an algorithm in pseudocode for SumKSmallest using the brute force paradigm. Indicate and justify (within a few sentences) the time complexity of your algorithm. b....
Consider the following algorithm Poly(A,a) --------------- 1. n = degree of polynomial (with coef A[n],..,A[0]) 2. sum = 0 3. for i = n downto 0 4. sum = sum * a +A[i] show all steps!! (a) Determine the running time of the algorithm, your work should explain your answer (b) what is the loop invariant property of the loop in line 3.
Consider the following decision problem: • Input: hGi where G is a graph. • Question: Does G contain a clique of size 3? Is this problem in P? Yes, no, unknown? Justify your answer (if your answer is “yes”, briefly describe a polynomial-time algorithm).
Consider the following algorithm (known as Horner's rule) to evaluate f(x) = sigma_i=0^x a, x^i; poly = 0; for(i=n; i>=0; i--) poly = x * poly + a_i a. Show how the steps are performed by this algorithm for x = 3, f(x) = 4x + 8x + x + 2. b. Explain why this algorithm works. c. What is the running time of this algorithm?
f(x) = 2.10 Consider the following algorithm (known as Horner's rule) to evaluate -ax': poly = 0; for( i=n; i>=0; i--) poly = x * poly + ai a. Show how the steps are performed by this algorithm for x = 3, f(x) = 4x + 8x + x + 2. b. Explain why this algorithm works. c. What is the running time of this algorithm?
a. (15 marks) i (7 marks) Consider the weighted directed graph below. Carry out the steps of Dijkstra's shortest path algorithm as covered in lectures, starting at vertex S. Consequently give the shortest path from S to vertex T and its length 6 A 2 3 4 S T F ii (2 marks) For a graph G = (V, E), what is the worst-case time complexity of the version of Dijkstra's shortest path algorithm examined in lectures? (Your answer should...
[10 marks] consider the following pseudocode: p := 0 x := 2fori:= 2ton p := (p + i ) * x a) How many addition(s) and multiplication(s) are performed by the above pseudocode?b) Express the time-complexity of the pseudocode using the big-Θ notation.) Trace the algorithm, below, then answer (c) and (d): Procedure xyz(n: integer) s := 0, for i:= 1 to n, for j:= 1to i, s:= s+ j*(i− j+ 1) return s c) What is the time-complexity for...