CSCI 303 Homework 3
Problem 1 (9-1): Given a set A of n numbers, we wish to nd the k largest in sorted order using a comparisonbased algorithm. Find the algorithm that implements each of the following methods with the best asymptotic worst-case running ti
CSCI 303 Homework 6
Problem 1 (31.1-1): Prove that there are innitely many primes. Solution 1: Assume that there are only nitely many primes, p1 , p2 , . . . , pk . Let
k
n=1+
i=1
pi
Then for all i cfw_1, 2, . . . , k , if you divide n by pi the remainder
CSCI 303 Homework 1
Problem 1 (2.1-1): Using Figure 2.2 as a model, illustrate the operation of Insertion-Sort on the array A = 31, 41, 59, 26, 41, 58 . Problem 2 (2.2-1): Express the function n3 /1000 100n2 100n + 3 in terms of -notation. Problem 3 (Deri
CSCI 303 Homework 7
In the following problems, N = cfw_1, 2, 3, . . . is the set of natural numbers, the symbol means "there exists", the symbol means "for all", the symbol means "halts", and the symbol means "does not halt". Bi (x) is the ith SBASIC prog
CSCI 303 Homework 7
In the following problems, N = cfw_1, 2, 3, . . . is the set of natural numbers, the symbol means there exists, the symbol means for all, the symbol means halts, and the symbol means does not halt. Bi (x) is the ith SBASIC program run
CSCI 303 Homework 6
Problem 1 (31.1-1): Prove that there are innitely many primes. Problem 2 (31.1-7): For any integer k > 0, we say that an integer n is a kth power if there exists an integer a such that ak = n. We say that n > 1 is a nontrivial power if
CSCI 303 Homework 2
Problem 1 (4.3-2): The recurrence T (n) = 7T (n/2) + n2 describes the running time of an algorithm A. A competing algorithm A has a running time of T (n) = aT (n/4) + n2 . What is the largest integer value for a such that A is asymptot
CSCI 303 Homework 2
Problem 1 (4.3-2): The recurrence T (n) = 7T (n/2) + n2 describes the running time of an algorithm A. A competing algorithm A has a running time of T (n) = aT (n/4) + n2 . What is the largest integer value for a such that A is asymptot
CSCI 303 Homework 3
Problem 1 (9-1): Given a set A of n numbers, we wish to nd the k largest in sorted order using a comparisonbased algorithm. Find the algorithm that implements each of the following methods with the best asymptotic worst-case running ti
CSCI 303 Homework 4
Problem 1 (6.1-1): What are the minimum and maximum numbers of elements in a heap of height h? Problem 2 (6.1-6): Is the sequence 23, 17, 14, 6, 13, 10, 1, 5, 7, 12 a max-heap? Problem 3 (6.2-1): Using Figure 6.2 as a model, illustrate
CSCI 303 Homework 4
Problem 1 (6.1-1): What are the minimum and maximum numbers of elements in a heap of height h? Solution 1: A heap is a semi-complete binary tree, so the minimum number of elements in a heap of height h is 2h , and the maximum number of
CSCI 303 Homework 5
Problem 1 (Not in book): Using the polynomial time reduction given in class, give an instance of the Directed Hamiltonian Cycle problem that corresponds to the instance of the 3-SAT problem where = (x1 x2 x3 ) (x1 x2 x1 ) (x2 x2 x3 ).
CSCI 303 Homework 5
Problem 1 (Not in book): Using the polynomial time reduction given in class, give an instance of the Directed Hamiltonian Cycle problem that corresponds to the instance of the 3-SAT problem where = (x1 x2 x3 ) (x1 x2 x1 ) (x2 x2 x3 ).