CS 4102, Algorithms
Problems Set #3, Spring 2010

Updated: Feb. 19, 2010, 5:15pm

Homework 3 is a "short" homework, worth less the HWs 1 and 2.  There are fewer problems to turn in, and most are simpler.  Also, you can work with up to three people in a group.  The main goal for HW3 is to make you look at the kind of problems from the most recent part of the course that might be on Exam 1.


To turn in:

Turn in solutions to these problems.  (Below they're marked with this image: Submit-Button)

Important: Put the answer to each question on a separate sheet of paper (or one problem on front and another on the back). This is to make grading easier for us.

Collaboration Rules for This Assignment:

  1. There are many problems here. There are five to submit.  For the ones that are not required to be submitted, you can collaborate or discuss in any way with as many people as you wish.
  2. For the required problems that you submit:
    1. You may submit your work on your own or with up to two partners.  If you work with a partner, you must pledge that all partners did approximately equal amounts of work on the required problems.
    2. If you work alone, you can discuss how to solve the problems with one other group or one other single person.  List the names of these people on your submission.
    3. If you don't understand the question or what it is asking, you can get clarification from other students only if this does not involve saying how the problem might be solved in any way.  If in doubt, don't discuss and see the TA or the instructor.
  3. Fill out the cover sheet on the website and submit it with your homework.

Problems from Algorithms textbook
(Solutions for problems marked "S" begin on page 656)

(Posted as Part of HW2) Problem Rec2: Submit-Button  (The grade will count as part of HW2.)

Use the either the Main Theorem or Master Theorem to give the order-class for each of the following recurrences. If you can't use either one of the theorems for a problem, just write "not applicable" and explain why.

(A) T(n) = 2T(n/2) + n

(B) T(n) = 2T(n/4) + n lg n

(C) T(n) = T(n/2) + lg n



Submit-Button Submit any two of the next three problems -- you chose!


Problem Sort-LB-1: 

Using a decision tree argument, state what the lower bound for the number of comparisons would be for an array of size 5. (This is the first part of Problem 5 on p. 256.)


Problem Invers-1: 

Describe a divide and conquer algorithm that counts the number of inversions in a list in o(n2) operations, and give the order-class (i.e. the BigTheta class) of your solution.
Big Hint:  To do this, take mergesort and modify it or add code to it in the merge algorithm. You will need to count something in merge (not mergesort) that contributes to the overall sum of the total number of inversions. Think about how merge works!  Look at simple example data.
Note: By "describe", I mean that you do not have to describe the complete code or pseudo-code if you can clearly explain how merge would be  modified.


Problem QS-Med3-1:
Let's say you implement Quicksort with the median-of-three method for choosing the pivot.  Write the recurrence relation for the worst-case performance for Quicksort with this enhancement.  Assume you are using a partition algorithm that requires n-1 comparisons for a list of size n.  Don't forget to include the cost (if any) of doing the median-of-three.  Note: You do not have to reduce the recurrence to closed form.