Comp Sci 1MD3
MidTerm I 2003
Dr. Jacques Carette
Name:
Student No.:
Duration : 50 minutes
•
This midterm contains 18 questions on 3 doublesided pages (including this one).
•
This midterm will be marked out of 50. There are 55 total marks available.
•
Answer the question in the space provided.
•
Do not separate the pages.
•
Make sure that you do not get stuck on one question; use your time wisely.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
1. Precisely define “Algorithm”. Give one consequence of the definition.
[3]
2. What “grouping” do the following algorithms belong to?
[3]
(a) quicksort
(b) shortest path in a graph (with positive weights)
(c) multiplication of
n
matrices of uneven sizes
3. How is the problem of ambiguity of algorithm representation usually solved?
[2]
4. Give an example (by name) of an algorithm in each of the following classes:
Θ(lg
n
),
Θ(
n
), Θ(
n
2
).
[3]
5. This question concerns the following pseudocode:
z
←
0;
x
←
1;
while (x
<
6) do
(z
←
z+x;
x
←
x+1)
(a) convert the pseudocode to a C code fragment which uses the same constructs. No
need to declare your variables.
[2]
2
This is the end of the preview.
Sign up
to
access the rest of the document.
 Winter '07
 various
 Imperative programming, int int int, extern int int, Dr. Jacques Carette

Click to edit the document details