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

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

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 = braceleftBigg 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
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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern