Sample Solution

Midterm Examination
CPSC 101: Connecting with Computer Science
The University of British Columbia
2013 Winter Term 1
Hassan Khosravi
Sample Solution
You have 45 minutes to solve the problems on this exam.
1. Each candidate must be prepared to produce, upon request, a UBCcard for identification.
2. Answer all the questions on this paper. The marks for each question are given in []. Use
this manage your time.
3. Candidates must not destroy or mutilate any examination material; must hand in all
examination papers; and must not take any
Marks
Max
examination material from the examination room Question
1
8
without permission of the invigilator.
4. No books (or other material) are allowed.
2
3
4
5
Total
10
10
4
8
40
5. Candidates suspected of any of the following, or
similar, dishonest practices shall be immediately
dismissed from the examination and shall be liable to disciplinary action:
a. • Having at the place of writing any books, papers or memoranda, calculators,
computers, sound or image players/recorders/transmitters (including telephones), or
other memory aid devices, other than those authorized by the examiners;
b. • Speaking or communicating with other candidates; and
c. • Purposely exposing written papers to the view of other candidates or imaging
devices. The plea of accident or forgetfulness shall not be received.
Good Luck
1. Strengths and weaknesses of human computer interfaces
a. Explain why computer programs often turn the mouse cursor to an
hourglass when they are performing a slow operation. [2 marks]
Useful feedback that they are currently completing a task
b. Explain why a driver may accidentally turn on the windshield wipers
instead of the turn signal when she’s driving a car that’s unfamiliar to her.
[2 marks]
Inconsistency or negative transfer across different cars
c. Explain why the car blinker that indicates turning left or right has a
blinking light as well as a ticking sound.[2 marks]
Blinking light is a well-chosen mapping
Ticking sound provides useful feedback that you are going to turn
One without the other is not good enough
d. This three-handled cup, a Tyg, was used in England in the late 1700s to
allow easy passing of a cup from person to person. Give one reason why
you think this design is not commonly used, and one way to improve the
design.[2 Marks]
Things that got mark
(1) Cups are inexpensive,
(2) This designed takes a lot of room
(3) It is hard to keep track of your handle
(4) It is not big enough for 3 people
(5) Hard to share between a mix of left/right handed people
(6) Cultural changes
Things that DIDN’T get mark:
(1) It is a stupid design
(2) Why would you want to share a cup
(3) Because it is a bad design
Improvements that got mark
Colour labels
Redesign so it is stackable
Make the cup bigger
Improvements that did not get mark
Remove two of the handles
2. Conversion between small instances of graphical and text based representations
a. Draw the hierarchical representation of the following expression:
(A + ((B - C) * D)) [5 Marks]
A
B
C
D
b. Convert this hierarchical representation to a text representation. [5 Marks]
(horse ((cat, dog)(giraffe (zebra, fish))))
3. HTML
a. Complete the following HTML code to generates this table: [5 Marks]
<table border="1">
<tr>
<td> <b> Name</b> </td>
<td> <b> Student Number </b> </td>
</tr>
<tr>
<td> Jane Doe </td>
<td> 12345 </td>
</tr>
</table>
b. Find and correct five bugs in the following fragment of code. [5 Marks]
...
<h1>Welcome to my site !<h1>
<img src: “mypic.png”/> <p> My favorite things :</p>
<li><ul> Chocolate </li> <li> Tea </li></ul>
<a src= “http ://www.facebook.com”>Find me on Facebook</a>
...
missing / in second <h1> (should be </h1>)
src : should be src= in img tag
first <li> should be <ul>
first <ul> should be <li>
src should be href in a tag
4. Commands in text based interfaces
a. Assume you have the directories ∼/play, ∼/play/test, and ∼/play/html. Say
you’re currently in directory ∼/play/test. Give two ways (one using
relative paths and one absolute) to change into directory ∼/play/html. [4
marks]
cd ~/play/html
cd ../html
5. Use of variables, and influence of file properties on computer applications
a. What is the value of variables a,b, and c after performing the following
calculation [5 marks]
a = 23
b= 32
c = 11
d = a + b – c // d=44
a= d – a // a= 21
b= c +a // b= 32
c = c +b // c= 43
a = a + b +c +d // 150
a
b
c
23
32
11
d
44
21
32
43
150
b. There is a folder called ’myWebsite’ on my desktop. Inside that folder is
an html file, called ’index.html’, which contains the html code for my
personal website. Describe what behavior you would expect when you
double click on the file. [1 marks]
The file would open in a browser if available.
c. The file is renamed once to index.txt and once to index.pdf. Describe what
behavior you would expect when you double click on the files. [2marks]
Index.pdf will generate an error or will not open properly
and index.txt will show the html code