Exam 1 Solution (120 pts)
Exam 1 Question 1 Solution (15pts)
[jeff]
<html>
<head>
<title>Hey Buddy</title>
</head>
<body>
<a href =
"http://www.cheapsuits.com/~billybob/">Billy
Bob</a>
</body>
</html>
Exam 1 Question 2 Solution (15pts)
[dan]
2. Write the HMTL code snippet to display a definition
list to show that
the word "glunch" means " a look of disdain, anger, or
dipleasure" and
the word "glumpy" means "sullen, morose, or
sulky."
- glunch
- a look of disdain, anger, or displeasure.
- glumpy
- sullen, morose, or sulky.
<DL>
<DT>glunch
<DD>a look
of disdain, anger,
or displeasure.
<DT>glumpy
<DD>sullen,
morose, or
sulky.
</DL>
Exam 1 Question 3 Solution (15pts)
[tanmay]
Write the HTML code snippet to make the elephant.jpg
image appear on the
right hand side of the page , with a big headline
reading "Elephants of
the
world unite !" on the left side of the page next to
it.
Elephants of the world unite!
HTML code for the above:
<img src="elephant.jpg" align="right">
<h1> Elephants of the world unite!
</h1>
Exam 1 Question 4 Solution (15pts)
[tanmay]
You want a webpage with two columns of text side by
side with space
between
the columns. Write the HTML code snippet to
accomplish this task
.
Welcome to The University of Iowa
Computer Science
Department's website.
The department office is located in 14 MacLean Hall.
Normal office hours
are
8:30 to Noon and 1:00 to 4:30 Monday through Friday.
The chair of the
department is Steve Bruell and the associate chair is
Jim Cremer.
|
The Department of Computer Science offers both the
undergraduate degrees
of
Bachelor of Arts and Bachelor of Science. A minor in
Computer Science is
also available. Graduate degrees offered include the
Master of Computer
Science, the Master of Science, and the Doctor of
Philosophy in Computer
Science. Information about admission is available on
our admissions
page.
|
HTML code for the above:
<table border=0 cellspacing=10 cellpadding=10
>
<tr>
<td>
some text in left column
</td>
<td>
some text in right column
</td>
</tr>
</table>
Exam 1 Question 5 Solution (15pts)
[dan]
5. Write the HTML code snippet for creating table of 3
columns and 2
rows with the elements of the first row being 10, A, 3
and the elements
of the second row being 5, B, C.
<TABLE BORDER>
<TR>
<TD> 10 </TD> <TD> A </TD>
<TD> 3
</TD>
</TR>
<TR>
<TD> 5 </TD> <TD> B </TD>
<TD> C
</TD>
</TR>
</TABLE>
Exam 1 Question 6 Solution (15pts)
[tanmay]
Write a simple form that will display a button that
contains the text :
"I
did it ! " and a checkbox labelled " Yes!" .
HTML code for the above:
<form name="form1">
<input type="button" name="button1" value="I
did it !">
<p>
<input type="checkbox" name="checkbox1">Yes!
</form>
Exam 1 Question 7 Solution (15pts)
[dan]
7. Write an algorithm that will swap the number in the
boxes labled "A"
and "B". Then determine which box is largest.
Fist create a third location called swapbox. The
value in box A goes
into swapbox, the value in box B goes into box A and
the value in
swapbox goes into box B.
if Box A > Box B
then Box A is the
largest
else
Box B is the
largest
Exam 1 Question 8 Solution (15pts)
[jeff]
1)
Use Bubble Sort to sort the names:
Compare Names[0] to Names[1]. If Names[1] is
'alphabetically before'*
Names[0], swap
them.If not do nothing. Next compare Names[1] and
Names[2]. If
Names[2]
is
'alphabetically before'* Names[1], swap them. If
not do nothing.
Continue these
pairwise comparisons over the rest of the list,
swapping when
necessary. Repeat
this process from the start of the list, only now
stop at Names[98]
because
Names[99] contains it's final value. Keep repeating
this process,
stopping one
element earlier each time until at least one of the
followingis true:
a
pass is
completed in which there are no swaps made or the
reduction by one
element has
left only Names[0] for the next pass.
2)
Use Selection Sort to sort the names:
Define a temp variable called "indexOfFirst". Make
the assignment
indexOfFirst = 0.
Compare Names[1] to Names[indexOfFirst]. If
Names[1] is
'alphabetically
before'* Names[indexOfFirst] then
set indexOfFirst = 1. If not do nothing. Compare
Names[2] to
Names[indexOfFirst]. If
Names[2] is
'alphabetically before'* Names[indexOfFirst] then
do indexOfFirst =
2.
If not do nothing.
Make this comparison for each of the rest of the
names in the list,
changing
the
value of indexOfFirst as necessary. When this pass
is complete do
temp
= Names[0],
Names[0] = Names[indexOfFirst], Names[indexOfFirst]
= temp (ie swap
the
name
that
is 'alphabetically first' with Names[0]). Make
another such pass over
the
list Names[1] - Names[99]. Repeat until the next
pass will include
only
Names[99].
Note. You were not expected to produce this next
paragraph.
* How to determine if one name is 'alphabetically
before' another?
If the names have last name first compare the first
letters of each
name.
(Can do this by comparing their ASCII codes or by
assigning each
letter
a number such as a = A = 01, b = B = 02, etc. and
comparing these
numbers.
The smaller number is closer to A. Or use another
way.) If these two
letters are the same compare the second letters of
each name. Keep
comparing letters until either: the letters don't
match or one name
runs out of letters(in which case I think the
shorter name comes
first).
3)
Step1. Create 26 lists, one for each letter in
the alphabet. Go
thru the Names[] array and add each
element to the list
that matches the 1st letter in that name.
Step2. Sort each of the 26 lists alphabetically
using Selection
Sort
(or Bubble Sort or a sort you
described).
Step3. Overwrite the Names[] array with the
contents of these
sorted
lists beginning with listA, then listB,
... , finally listZ.