December 2005 Examinations
CSC 104H1F
Duration: 3 hours
No aids allowed
Make sure you have all 11 pages (including this page). (Don't panic about the page count -- there's lots of space for answers.)
Answer all questions. Answer questions in the space provided. Answers not in the correct space will not be graded unless a note in the correct space says "see page ..." and the answer on that page is clearly labelled with the question number.
Be careful not to get stuck on some questions to the complete exclusion of others. The amount of marks or answer-space allotted does not indicate how long it will take you to complete the question, nor does the size of the answer-space indicate the size of the correct answer.
1. [9 marks]
Suppose that you are writing a procedure to tell someone how to go to the
CDF computer labs.
The procedure says that they can go to either BA 2220 or BA 3175.
a) What about that instruction disqualifies this procedure from being called an "algorithm"? Why?
b) Why is this defect in the procedure harmful if we were trying to build a robot or other computational device to follow this procedure?
c) How could we modify the procedure so as to be a valid algorithm?
[solution]
2. [6 marks]
Consider the following filesystem hierarchy:
a) Write an absolute path name to specify susan's file "HOWTO".
b) Suppose that I have just logged in and my (ajr's) home directory is my "current working directory". Write a relative path name for me to specify my "typing.html" file.
c) If this is my (ajr's) CDF account, specify a URL which would access that typing.html file from a web browser on any machine on the internet.
[solution]
3. [6 marks] Identify the components of this URL and their meaning:
http://www.cdf.toronto.edu/~c5fred/moths/overview.html
[solution]
4. [4 marks] Give an example of a situation in which you would prefer to use the KDE main menu (lower-left of the screen) to start an application program, and give an example of a situation in which you would prefer to start the program by typing its name in a terminal window.
[solution]
5. [10 marks]
On the CDF computers, how do you (answer very briefly):
a) get to a "terminal window"?
b) start the "IDLE" IDE for Python?
[we're using a different IDE these days, but the procedure
is similar]
c) view the contents of a (short) text file?
d) examine the list of names of files in the directory /etc ?
e) log out?
[solution]
6. [12 marks]
Write HTML code to produce a web page which looks like the following.
There is no available character for
""
but there is a small picture file you can use (just as was done in assignment
three for
) at
http://www.dgp.toronto.edu/~ajr/gen/13.gif
(You can skip copying out all of the words below so long as your intention is
clear.)
Vinyl Records
Vinyl records were recorded at different speeds. Standard speeds were 16, 33, 45, and 78 RPM.Some people miss them, but I like CDs much better.
[solution]
7. [15 marks]
In a mathematics course, there are two mid-term tests, each worth 25%, plus
bi-weekly homework assignments, worth a total of 10%.
This yields a "term mark" worth 60%, and the final exam is worth 40%.
However, if you do better on the final exam than on the term work, then the
final exam counts for 100%.
Here is a grades spreadsheet for a single student:
Write formulas for the following spreadsheet cells (all of the other cells are inputs):
F14:
C12:
C13:
C14:
C15:
[solution]
8. [15 marks]
a) Write a Python program to print the integers (whole numbers) from 10 to 20, inclusive, using a loop.
b) Write a Python program to prompt the user for their name and then say "hello" using their name (e.g. "Hello, Alan").
c) What does the following Python program output?
x = 3 y = x + x y = y + y y = x + y print y
d) What does the following Python program output?
x = 2 while x < 30: x = x * 5 print x
e) What does the following Python program output?
for i in range(2,5): print 'z' * i
9. [13 marks]
a) Convert the following base ten numbers to binary.
28
7
b) Convert the following binary numbers to base ten.
10010
10101
1110
c) In assignment four's "Hanoi" program, the binary representation of the number controlled which disk was moved. Which disk would be moved for each of the numbers in part b?
(obviously, part (c) is not a possible exam question this year because of a different assignment four)
[solution]
10. [10 marks]
(Note: This question is the A+ question: very difficult for most students.
Do the rest of the exam first!)
We can factor a number by repeatedly finding the lowest integer (starting from two) which divides evenly into it, printing that number, dividing by it (i.e. x = x / d), and repeating until we're left with 1.
For example, let's factor the number 12.
Another example: factor the number 15.
Write a program which factors an input number. You can assume that the number is a positive integer. (Print the factors as you go; there is no need for a summary statement at the end.)
[solution]
End of exam. Total marks: 100. Total pages: 11.