Assignment 07
Contents:
Overview
Topic: Algorithms
Related Reading: Ch. 6.1, 9.4, 9.5 and pp. 518-525
Due: 9am Thursday, 1 August 2002
Internet Requirements
You will need an Internet connection for completing the assignment as
well as submission.
Practice Problems
Problems to be Submitted (20 points)
- (4 points)
Exercise 12 of Ch. 9 (p. 314)
- (5 points)
Exercise 13 of Ch. 9 (p. 314)
Though it does not state this explicitly, please answer this
question in reference to the Quicksort algorithm
- (5 points)
Variant of Exercise 15 of Ch. 9 (p. 315).
For this problem, do not just report the number of comparisons, rather
report the exact sequence of items against which the target was compared.
- (3 points)
What is the output generated when the following recursive routine is
called as Test1(1):
Test1(Count)
if (Count<5) then
print Count
call Test1(Count+1)
endif
- (3 points)
What is the output generated when the following recursive routine is
called as Test2(1):
Test2(Count)
if (Count<5) then
call Test2(Count+1)
print Count
endif
Overall, please type your answers to all of the problems in a
single document to be submitted electronically. Please see details about the
submission process.
Extra Credit (2 points)
The goal here is to really challenge your understanding of recursive
procedures. A classic problem, known as the
Towers
of Hanoi can be solved with the following recursive procedure:
Towers(n,A,B,C)
if (n>0) then
Call Towers(n-1,A,C,B)
Print "Move ring <n> from <A> to <C>"
Call Towers(n-1,B,A,C)
To prove your understanding, please describe the precise output which
is generated when a call is made as Towers(4,X,Y,Z).
ns121 Class Page
visprof@coloradocollege.edu