Read the entire problem set thoroughly before beginning to write your solutions.
Your solution should be typed and printed with plenty of spacing within and between problems in black ink on single-sided, otherwise blank paper that is stapled (assuming it is more than one page, which it should be). If solutions to certain problems would be aided by diagrams or figures that are easier to render by hand, that is fine, but make sure what you write is legible.
Show your work.
Do the problem set on your own. If you need assistance, ask questions of your instructor in class, in group conference, via email, or make and appointment with him to discuss the assignment in more detail.
Write an algorithm, in the style presented in Chapter 1 to illustrate how to play a game of your choice (a board game, a card game, tic-tac-toe, Sudoku, a computer game, or a sport). Choose a game that you a) know well and b) can present how to play succinctly: you should aim for your algorithm to have at least five steps and no more than fifteen. If the game involves more than one player, you can either use the algorithm to illustrate the overall course of play or to illustrate how the actions of one player. What assumptions of the reader are you making in order for the algorithm to be considered unambiguous?
From the course text, Chapter 1 (p. 34): exercise 6.
From the course text, Chapter 2 (p. 75): exercises 3 and 8.
Consider the following algorithm:
input m; W1, W2, ..., Wm
j ← m
while j > 0:
print Wj
j ← j - 1
G, N, I, K, R, U, L (m = 7)
In a clear and concise sentence explain what this algorithm does.
How many steps does this algorithm perform in the best and worst case, in terms of m? What is its order of magnitude worst-case complexity?
From the course text, Chapter 3 (p. 122): exercises 17 and 21.
Bubble sort (see p. 121)
From the course text, Chapter 3 (p. 121): exercise 8b.
What is the best- and worst-case number of comparisons when bubble sort is employed on a list of n items?
What is the best- and worst-case number of exchanges when bubble sort is employed on a list of n items?
From the course text, Chapter 3 (p. 123): exercise 28b. Does the question provide enough information to give a precise answer? Explain.
For this problem, you should first do a little research on the Sarah Lawrence library catalog.
How many books, approximately, are stored in the catalog? How many books, approximately, are added to the catalog on a weekly basis?
What sort of searching algorithms do you think are employed when you search for a book by the last name of its author? Explain your reasoning.
How often do you think sorting algorithms are employed to maintain the catalog: constantly; every time you search; less frequently; or never? Explain.
Consider the following algorithm:
input c
b ← 1
while b ≤ c:
s ← 0
a ← 1
while a ≤ b:
s ← s + a
a ← a + 1
print s
b ← b + 1
What does this procedure print if given 4 as its input?
In a clear and concise sentence explain what this algorithm does.
How many steps does this algorithm perform in the best and worst case, in terms of c? What is its order of magnitude worst-case complexity?
Write a more efficient algorithm to accomplish the same task. Answer the previous pair of questions for your algorithm.
When analyzing the efficiency of algorithms, we have focused primarily on time requirements. Historically, computer scientists have been at least as concerned with space (memory, disk/tape storage) requirements, but over the last few decades they have shifted their concerns to focus more and more on time. Why do you think this has happened? Do you think it says more about the advance of science and technology or more about societal trends? Explain. Are there are other resources that are consumed when we solve problems via computer that you think are or will become more important than time and space? Explain.