Saint Louis University |
Computer Science 314
|
Dept. of Math & Computer Science |
Topics:
Related Reading: Chapters 1, 2, 3, 8, and 10 of CLRS
Due:
10:00am, Monday, September 8, 2014
Please make sure to strictly adhere to the stated course procedures regarding the format of your submitted homework. In particular, your name should not appear on anything other than the cover page, and your solution for each problem must be in a separate packet, labeled appropriately with your assigned codename.
You must also adhere to the policies on academic integrity, paying particular attention to the limits on collaboration.
Problem 2-1 (starting on page 39 of CLRS)
Problem 8-6 (on page 208 of CLRS)
Exercise 10.3-4 (on page 245 of CLRS). To be sufficiently rigorous, your solution should include complete pseudocode, using the style of that chapter, and an explanation regarding the correctness and efficiency of your solution. Although not stated in the book's problem, it is important that both of your operations still run in O(1) time.
I'd also like to note that I find the book's hint about an "array implementation of a stack" to be more misleading that it is useful. I suggest ignoring that entirely.
Exercise 10.2-8 (on page 241 of CLRS). To be sufficiently rigorous, your solution should include complete pseudocode, using the style of that chapter, and an explanation regarding the correctness and efficiency of your solution.
Assume that we have a sequence of n numbers containing all the integers from 0 to n except one, in arbitrary order. The goal is to efficiently determine which number is missing. However, the numbers are represented in binary. For example, the input for n=5 might be modeled as:
1 | 0 | 1 |
0 | 1 | 1 |
0 | 1 | 0 |
0 | 0 | 0 |
0 | 0 | 1 |
In solving the problem, you will be charged for each bit of the input that is examined. Therefore, at the beginning of the process for a given n, the unknown input might be viewed as follows:
? | ? | ? |
? | ? | ? |
? | ? | ? |
? | ? | ? |
? | ? | ? |
Problem 4-5 (starting on page 109 of CLRS)