h1 - recurrence equation. The pseudocode for bubble sort is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COMPSCI 342-001 Data Structures and Algorithms (Fall 2011) Homework 1 (70 points), Due on 9/07/2011 (Wednesday) 1. (10 points) Suppose that a computer does not know how to compute the value C n 2 directly if n > 2, but the computer can return C 2 2 = 1 in constant time. Also, the computer takes only constant time for arithmetic operations. We can use divide and Conquer technique to compute C n 2 as follows. C n 2 = b 1 if n = 2 2 C n/ 2 2 + ( n/ 2) 2 if n = 2 k , where k > 1 is a positive integer Please write down the running time recurrence if C n 2 is computed using the above approach. 2. (10 points) Please analyse the bubble sort algorithm by the three steps - divide, con- quer and combine (as we discussed in class), and then write down the running time
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: recurrence equation. The pseudocode for bubble sort is as follows: bubble-sort(A, p, r) // p: starting index; r: ending index 1. if p < r 2. for i <-- p to r-1 3. do if A[i] > A[i+1] 4. then exchange A[i] <-> A[i+1]; 5. bubble-sort(A, p, r-1) 3. (15 points) Problem 2-1 parts a, b, c on page 39 of the textbook. 4. (10 points) Please use the basic deFnition of Θ notation to show 1 5 n 2-2 n-100 = Θ( n 2 ). 5. (10 points) Exercise 3.1-4 on page 53 of the book. 6. (15 points) Problem 3-2 on page 61 of the book. 1...
View Full Document

This document was uploaded on 11/01/2011 for the course COMPSCI 342 at Boise State.

Ask a homework question - tutors are online