Question/Answer Sheet COMPSCI 111/111G
THE UNIVERSITY OF AUCKLAND
SUMMER SEMESTER, 2012
Campus: City
COMPUTER SCIENCE
Mastering Cyberspace: An Introduction to Practical Computing
(Time Allowed: TWO hours)
NOTE:
You must answer all questions in this exam.
No calculators are permitted
Write your answers in the space provided in this booklet.
There is space at the back for answers that overflow the allotted space.
Surname Sample
Forenames Answers
Student ID
Login (UPI)
Question Mark Out Of
1 Hardware and Software 15
2 Internet 15
3 Programming using Python 10
4 Spreadsheets 14
5 XHTML and CSS 12
6 Databases 14
7 LaTeX 12
8 AI and Social Issues 8
TOTAL 100 100
CONTINUED
Question/Answer Sheet -2- COMPSCI 111/111G
ID..…………………….
1. Hardware and Software (15 marks)
(a) List three pieces of hardware you would find inside the system unit.
Cooling fans
Motherboard
Power Unit
CD Drives
Hard Drive
CPU
Expansion slots/cards, etc...
(3 marks)
(b) Describe Moore’s Law.
The number of transistors that can fit on a single chip approximately doubles
every 18 months, but the price remains the same. Therefore, computing power
roughly doubles every one and a half years.
(3 marks)
(c) What decimal number does the binary number 1000 correspond to?
(2 marks)
CONTINUED
Question/Answer Sheet -3- COMPSCI 111/111G
ID..…………………….
(d) Both crippleware and nagware are types of shareware. Explain how each type works.
Crippleware: disables certain features of functions that the software offers
unless the product is purchased. For example, a word processor that doesn't
allow you to print.
Nagware: constantly reminds the user that they should purchase the software,
if they wish to continue to use it.
(4 marks)
(e) Explain the problem that causes most CPU's sold today to have clock speeds that don't
exceed 4.0 GHz. What has been the solution to this problem?
Because of issues to do with the heat generated. Once CPU speeds approach
4.0 GHz, the use of standard cooling fans is no longer sufficient to handle
overheating issues. The solution to this problem has been to add extra
processors in parallel, e.g. dual core and quad core processors.
(3 marks)
CONTINUED
Question/Answer Sheet -4- COMPSCI 111/111G
ID..…………………….
2. Internet (15 marks)
(a) Identify the protocol, domain, path and file requested by the following URL:
http://www.cs.auckland.ac.nz/courses/compsci111/lectures.html
protocol: http
domain: www.cs.auckland.ac.nz
path: /courses/compsci111/
file: lectures.html
(4 marks)
(b) List four locations where logs of Internet traffic are kept.
1) Browser
2) OS
3) ISP Server
4) Destination Server
(4 marks)
(c) Briefly explain what a cache does in regard to requesting a webpage over the Internet.
It stores a local copy of the website and first determines whether the local
copy is up-to-date. If so, it returns the local copy and there's no need to ask
the server for a copy of the site, otherwise the most recent copy is requested
from the server.
(3 marks)
CONTINUED
Question/Answer Sheet -5- COMPSCI 111/111G
ID..…………………….
(d) State two advantages and two disadvantages of wikis.
Advantages:
Creates a central pool of content
Everyone can contribute
Easy to use
Quick to develop material
Disadvantages:
No quality control
Anyone can contribute
Information changes rapidly
Vandalism a possibility
(4 marks)
CONTINUED
Question/Answer Sheet -6- COMPSCI 111/111G
ID..…………………….
3. Programming using Python (10 marks)
(a) Write a program that calculates and displays the amount of memory required to store
a bitmap image which has 4 colours. At the beginning, the user is asked to enter the
width and height of the image.
The number of bits required is calculated using the following formula (Note that 2
bits per pixel are required to store an image with 4 colours):
bits required = width * height * 2
If the required number of bits is less than 8, then the amount of memory required is
displayed in bits, otherwise it is displayed in bytes. To convert the number of bits to
a number of bytes, divide by 8.
Example 1: If the user entered 4 for the width and 3 for the height, the output that is
expected from your program is shown below:
Enter width: 4
Enter height: 3
Memory required is 3 bytes
Example 2: If the user entered 1 for the width and 3 for the height, the output that is
expected from your program is shown below:
Enter width: 1
Enter height: 3
Memory required is 6 bits
width = int(input("Enter width: "))
height = int(input("Enter height: "))
bitsRequired = width * height * 2
if bitsRequired < 8:
print("Memory required is", bitsRequired, "bits")
else:
bytesRequired = bitsRequired // 8
print("Memory required is", bytesRequired, "bytes")
(5 marks)
CONTINUED
Question/Answer Sheet -7- COMPSCI 111/111G
ID..…………………….
(b) Complete the output produced by the following program when the user enters 5 at the
prompt.
numberEntered = int(input("Please enter a number: "))
counter = numberEntered
while counter > 0:
if counter % 4 == 0:
print(counter, " modulo 4 is zero")
if counter % 4 == 1:
print(counter, " modulo 4 is one")
if counter % 4 == 2:
print(counter, " modulo 4 is two")
if counter % 4 == 3:
print(counter, " modulo 4 is three")
counter = counter - 1
print("counter: ", counter)
Please enter a number: 5
5 modulo 4 is one
4 modulo 4 is zero
3 modulo 4 is three
2 modulo 4 is two
1 modulo 4 is one
counter: 0
(5 marks)
CONTINUED
Question/Answer Sheet -8- COMPSCI 111/111G
ID..…………………….
4. Spreadsheets (14 marks)
Questions (a) to (e) refer to the spreadsheet shown below. On the upper left side the
spreadsheet shows a table of different length units with their conversion factors. The upper
right side of the spreadsheet shows a list of sample conversions.
(a) In cell D13 the highest conversion factor from the table directly above is shown. What
is the best formula to use in cell D13?
= MAX(D4:D10)
(2 marks)
(b) Cell G13 records whether the conversion factor in cell D13 is greater than the number
in cell G12 (“Y”), or not (“N”). What is the best formula to use in cell G13?
Note: The formula must be able to be filled right.
= IF ($D$13 > G12, "Y", "N")
(3 marks)
CONTINUED
Question/Answer Sheet -9- COMPSCI 111/111G
ID..…………………….
(c) Cell E13 uses a VLOOKUP formula to look up the unit of the conversion factor in cell
D13.
The syntax of the vlookup function to search the first column of a table, and then
return a value from any cell on the same row of the table is given below:
vlookup(lookup_value, table_array, col_index_num,[range_lookup])
What is the best formula to use in cell E13? The formula must use the VLOOKUP
function to get the appropriate unit from the table in cells D4:E10
= VLOOKUP (D13, $D$4:$E$10, 2, FALSE)
(3 marks)
(d) What is the best formula to use in cell J4? Note: The formula must be able to be filled
down.
= VLOOKUP (I4, $C$4:$D$10, 2, FALSE) * H4
(3 marks)
(e) K13 displays the total number of cells in the range G13:J13 that contain “Y”. What is
the best formula to use in cell K13?
= COUNTIF (G13:J13, "Y")
(3 marks)
CONTINUED
Question/Answer Sheet - 10 - COMPSCI 111/111G
ID..…………………….
5. XHTML and CSS (12 marks)
The following screenshot shows a web page created using XHTML 1.0 strict and
Cascading Style Sheets:
Complete the XHTML code below so that it produces the output shown above. You
must use the styles defined in the internal style sheet in the head section below, and
must not define any new styles.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Film Night!</title>
<style type="text/css">
CONTINUED
Question/Answer Sheet - 11 - COMPSCI 111/111G
ID..…………………….
h1
{
text-align: center;
font-family: serif;
font-variant: small-caps;
}
h2
{
font-style: italic;
text-transform: lowercase;
}
.toprow
{
text-align: center;
font-weight: bold;
font-size: x-large;
}
#midnight
{
font-family: "Comic Sans MS", cursive;
}
</style>
</head>
<body>
<!-- Main heading -->
<h1>Movie Showtimes</h1>
(1 mark)
<table border="1px">
<!-- Large and centred table header text -->
<tr class = "toprow">
<td>Time</td>
<td>Movie</td>
</tr>
(2 marks)
CONTINUED
Question/Answer Sheet - 12 - COMPSCI 111/111G
ID..…………………….
<!-- Remaining table detail rows -->
<tr>
<td>8.00pm</td>
<td>Leaving Las Vegas</td>
</tr>
<tr>
<td>10.00pm</td>
<td>Requiem for a Dream</td>
</tr>
<tr>
<td id = "midnight">Midnight</td>
<td>Pink Flamingos</td>
</tr>
(3 marks)
</table>
<!-- Horizontal ruled line -->
<hr/>
(1 mark)
<!-- Lowercase subheading -->
<h2>further details</h2>
(1 mark)
CONTINUED
Question/Answer Sheet - 13 - COMPSCI 111/111G
ID..…………………….
<!-- Ordered list -->
<ol>
<li>All Tickets $10.00</li>
<li>Unallocated Seating</li>
</ol>
(2 marks)
<!-- Final paragraph -->
<!-- hyperlink should proceed to "http://www.checkout.co.nz" -->
<p>
Purchase tickets <a href="http://www.checkout.co.nz">here</a>
</p>
(2 marks)
</body>
</html>
CONTINUED
Question/Answer Sheet - 14 - COMPSCI 111/111G
ID..…………………….
6. Databases (14 marks)
(a) What is the difference between a one-to-one relationship and a one-to-many
relationship?
In a one-to-one relationship a single record is associated with a single record
in another table and vice versa.
In a one-to-many relationship a record from one table can be associated with
many records in another table.
(4 marks)
The following Microsoft Access relationship diagram is used in questions (b), (c) and (d):
(b) State the primary key(s) of the Images table above.
Path
(1 mark)
(c) State the foreign key(s) (if any) of the Sighting table above.
TripID
(2 marks)
CONTINUED
Question/Answer Sheet - 15 - COMPSCI 111/111G
ID..…………………….
(d) What would be an appropriate data type for the Comments field of the Trip table?
Text
(1 mark)
The following Query By Example (QBE) diagram is used in questions (e) and (f):
(e) Explain what the above Query By Example (QBE) does.
It displays the Species and FoundTime of all records in the Sighting table
which have a temperature higher than 50.
(3 marks)
(f) Write the SQL statement that would give the same output as the above QBE.
SELECT Species, FoundTime
FROM Sighting
WHERE Temperature > 50;
(3 marks)
CONTINUED
Question/Answer Sheet - 16 - COMPSCI 111/111G
ID..…………………….
7. LaTeX (12 marks)
(a) On the following page, write the LaTeX code that will produce the following output:
The following commands have been included as a reference. You will not need to use all
of these commands. Note that the basic document structure has been completed for you.
Normal commands Environments Math mode commands
\emph{} itemize $
\section{} enumerate \sum_{}^{}
\subsection{} verbatim \frac{}{}
\large flushright \sqrt{}
\textbf{} center \geq
\title{} quote \pi
\author{} displaymath \infty
\date{} equation
^
\maketitle emph
_
\item
\%
CONTINUED
Question/Answer Sheet - 17 - COMPSCI 111/111G
ID..…………………….
\documentclass[a4paper]{article}
\begin{document}
\section{111 Exam}
\subsection{Latex}
Latex has different document classes:
\begin{itemize}
\item Book
\item Report
\item Article
\item Letter
\end{itemize}
To annotate a document the $\%$ sign has to be used in front of each line.
What latex really excels in are formula as the following example shows:
\begin{equation}
c = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}
\end{equation}
\end{document}
(8 marks)
CONTINUED
Question/Answer Sheet - 18 - COMPSCI 111/111G
ID..…………………….
(b) Draw the output that would be generated by the following LaTeX code. If quote marks
appear, make it clear what type will appear.
\documentclass[a4paper]{article}
\begin{document}
\title{A Short Story}
\author{Mister X}
\maketitle
\section{Chapter 1}
\subsection{Tim and the Dragon}
\emph{On} the possibly last day of his life, Tim got up at 10
a.m. after a night out with his friends.
\begin{quote}
``What a wonderful day,'' he said.
\end{quote}
\begin{flushright}
Grandma waited in the kitchen.
\end{flushright}
\end{document}
(4 marks)
CONTINUED
Question/Answer Sheet - 19 - COMPSCI 111/111G
ID..…………………….
8. Artificial Intelligence and Social Issues (8 marks)
(a) Name three other disciplines from which AI inherited ideas.
Biology, Philosophy, Mathematics, Neuroscience, Psychology
(3 marks)
(b) Name one type of task to which AI can be applied, and briefly explain how it can be
applied.
Tasks that improve human computer interaction.
Applications: Recognition of Faces, Emotions, Handwriting, Speech, Objects
Speech production, Natural language queries, Conversation
(3 marks)
(c) Name two methods that parents can use to protect their children from Internet dangers.
Filtering, Blocking, Putting the computer in a public area
(2 marks)
CONTINUED
Question/Answer Sheet - 20 - COMPSCI 111/111G
ID..…………………….
- Overflow Sheet 1 -
Write the question number and letter next to your answer. You must ALSO indicate in
the allotted space that you have used the overflow sheet.
CONTINUED
Question/Answer Sheet - 21 - COMPSCI 111/111G
ID..…………………….
- Overflow Sheet 2 -
Write the question number and letter next to your answer. You must ALSO indicate in
the allotted space that you have used the overflow sheet.
CONTINUED
Question/Answer Sheet - 22 - COMPSCI 111/111G
ID..…………………….
- Overflow Sheet 3 -
Write the question number and letter next to your answer. You must ALSO indicate in
the allotted space that you have used the overflow sheet
CONTINUED
Question/Answer Sheet - 23 - COMPSCI 111/111G
ID..…………………….
Rough Working – This page will not be marked
CONTINUED
Question/Answer Sheet - 24 - COMPSCI 111/111G
ID..…………………….
Rough Working – This page will not be marked