Assignment #2 SOlution

$30.00 $24.90

Description

Please upload your submission as a single PDF le on D2L. If your submission consists of more than one le, convert all your les into a single PDF le and upload it.

  1. Assuming P 6= NP, for each of the problems below, say whether it is solvable in polynomial time or whether it is NP-complete, and justify your answer. (That is, if you say that the problem is polynomial-time solvable, explain how it can be solved in polynomial time; and if you say that it is NP-complete, give a polynomial-time reduction from an NP-complete problem to it.)

    1. Given n coins of two di erent denominations (values), that is some coins are worth x dollars and some are worth y dollars, decide if the coins can be partitioned into two parts that have the same monetary value.

    1. Given n checks, each of arbitrary (integer) monetary value, decide if the checks can be partitioned into two parts that have the same monetary value.

    1. Given an undirected graph G, decide if G has an independent set of 5 vertices.

  1. Illustrate the execution of Merge Sort on the array A = h6; 4; 9; 8; 5; 10; 1; 3i. Regarding the level of illustration, follow the level of illustration done

in class but complete the illustration until the end (array is sorted).

  1. Illustrate the execution of Quick Sort on the array A = h6; 4; 9; 8; 5; 10; 1; 3i. Please use the version of Quick Sort discussed in class, which is the same as the one covered in the textbook. Regarding the level of illus-tration, follow the level of illustration done in class but complete the illustration until the end (array is sorted).

  1. Suppose that we are given an array A[1::n] of integers such that

A[1] < A[2] < : : : < A[n]. Give an O(lg n) time algorithm to decide if there exists an index 1 i n such that A[i] = i.

  1. Textbook, pages 39-40, problem 2-1, parts a, b, and c.