CS 105 Midterm Examination Solutions
Thursday, March 16, 2000
NAME:
There are 7 questions on this examination. The point values associated with the questions are shown in the table above. You have 75 minutes to complete the examination. You should not consult any references while completing this examination. Show all answers in the spaces provided in the examination booklet. Paper for scrap work will be made available.
Question Points Score 1 16 2 20 3 20 4 12 5 12 6 12 7 8 TOTAL 100
For this problem, I would like you to consider the frequency with which the abrupt transitions occur using on-off keying and Manchester encoding. For each of the following questions, assume that data is being transmitted at a rate of 1000 bits per second.
When on-off keying is used, a sequence of alternating 0's and 1's produces the maximum transmission rate. Since every bit sent differs from the bit preceding it, there will be a transition at the end of each bit. Accordingly, if the transmission rate is 1000 bit/second, then the maximum transition rate would be 1000 transitions/second.
When on-off keying is used, a sequence consisting of repeated 0's or 1's produces the minimum transition rate. If the data being sent is "0000000000...", there will no not transitions at all. Regardless of the transmission rate, the transition rate will be 0 transitions/second.
When Manchester Encoding is used, a sequence consisting of repeated copies of the same bit value (either all 0's or all 1's) produces the maximum transition rate. For any signal sent using Manchester encoding there will be a transition positioned in the middle of each bit's sending time. If a bit is identical to the bit sent before it, then the final state of the signal (high or low) at the end of the first bit will differ from the state of the signal required for the beginning of the following bit. So, there will also have to be a transition between each pair of such bits. Accordingly, if all the bits sent are the same there will be a transition in the middle and at the end of each bit sent. Given a rate of 1000 bits/second this will produce a rate of 2000 transitions/second.
When Manchester encoding is used a sequence in which 0's and 1' alternate produces the minimum transmission rate. When such a sequence is transmitted, there will be a transition in the middle of each bit sent, but no transitions will be necessary between adjacent bits. At the data rate of 1000 bits/second this will correspond to a rate of 1000 transitions/second.
When a baseband transmission technique is used, the transmission rate is limited by the fact that the square waves in the original signal tend to spread out as the signal moves down the wire (because the different ferquency sine waves of which the square wave is composed travel at different speeds). The closer together the original square waves are, the sooner this spreading causes them to overlap making the signal unintelligible. It is really the transition rate that determines how close together the original square waves are. As a result, the maximum bit rate possible using Manchester on a given cable would be half that possible with on-off keying.
False. Morse code actually uses five symbols: dot, dash, short pause, medium pause, and long pause.
True. The "A" tag is a text-level tag. Luckily "IMG" tags are considered "text-level items" by HTML, so images can be used as links.
False. The period of a wave is related to its frequency, but not to its amplitude. Amplitude measures the "height" of a wave rather than its "width".
True. The 8-bit entries used for pixels are only capable of identifying 256 distinct palette entries.
False. Frequency division multiplexing can be used in many other transmission media. For example, frequency division multiplexing is used in radio and TV transmission (i.e. through the air). Otherwise, there could only be one TV station or one radio station.
True. As transmission speed increases the time "wasted" waiting for the token becomes relatively more significant so the efficiency with which data is transmitted decreases. Even though the efficiency is lower, the actual transmission rate does increase.
True. Since the color values needed to describe an image are encoded in a JPEG file using an approximating function based on component funtions that vary smoothly (cosine functions), images with sharp divisions between regions of different colors tend to be distorted more than images in which color transitions are gradual.
False. Circuit switching is still used for telephone calls.
True.
True (at least it is supposed to be true!).
For each example, please briefly explain the problems with the HTML shown and indicate how to modify the HTML to make it correct while producing what the author appeared to have in mind. It is more important that your revised code be correct than that it perfectly capture the intent of the original. In fact, in some cases, the problems with the HTML given may be severe enough that several different interpretations of "what the author appeared to have in mind" may be possible.
You can either clearly mark up the code shown or write a complete revision in the space provided.
<FONT COLOR="#990099">
<H3>
YOUR LINKS TO THE WORLD!!
</H3>
</FONT>
Problems: It is illegal to enclose a block level tag (like <H3>) within a text level tag (like FONT).Correction: <H3> <FONT COLOR="#990099"> YOUR LINKS TO THE WORLD!! </FONT> </H3>
<H2>
<P ALIGN="Center">
<FONT COLOR="#FF0000">
<FONT COLOR="#00CC66">
People
</FONT>
</FONT>
</P>
</H2>
Problems: It is illegal to nest anything but text tags within either a header tag or a paragraph tag. So, placing a P tag within an H2 tag is illegal. It is also pointless to nest two font tags specifying different colors around a single piece of text. Only the inner color setting will be effective. In correcting this code, it seems reasonable to assume that the text is intended to function as a header and that the P tag was only added to control alignment. So, it is appropriate to move the alignment attribute to the H2 tag.Correction: <H2 ALIGN="Center"> <FONT COLOR="#00CC66"> People </FONT> </H2>
<OL >
<FONT COLOR= "#FF0066">
<H4> Top Ten List</H4>
<LI>Miami</LI>
<LI>Boston</LI>
... imagine eight more items ...
</OL>
Problems: Within OL tags, only items preceded by <LI> tags are allowed. So, the FONT tag and H4 tag shown would be illegal. Also, the FONT tag needs to be closed. It is unclear whether the author's intend was to just change the color of the heading or to change the color of all the list items. Below, I have assumed the color of all the text was supposed to be changed (since this is the harder thing to do). The alternative (leaving out the FONT tags in all the LI's) would be just as reasonable a correction.Correction: <H4> <FONT COLOR= "#FF0066">Top Ten List </FONT> </H4> <OL > <LI><FONT COLOR= "#FF0066">Miami </FONT></LI> <LI><FONT COLOR= "#FF0066">Boston</FONT></LI> ... imagine eight more items ... </OL>
<HTML>
<HEAD>
<TITLE>Image Gallery</TITLE>
</HEAD>
<HEAD>
<B>
<FONT SIZE="4">
<FONT SIZE="6">
Lab #2: Image Gallery
</FONT>
</FONT>
</B>
</HEAD>
<BODY>
<P>
This is a page showing the images created in lab #2 using Adobe Photoshop.
.
.
.
</BODY>
</HTML>
Problems: First, this sample has an extra set of <HEAD>...</HEAD> tags surrounding HTML that really belongs within the BODY tag pairs. Next, it has redundant FONT size specifications applied to the text "Lab ...". Finally, the combination of code to increase the font size and use boldface suggests that the text should really be treated as a header. (While appropriate, this last suggested change is not required to make the HTML correct.)Correction: <HTML> <HEAD> <TITLE>Image Gallery</TITLE> </HEAD> <BODY> <H2> Lab #2: Image Gallery </H2> <P> This is a page showing the images created in lab #2 using Adobe Photoshop. . . . </BODY> </HTML>
<TABLE BORDER=0 CELLSPACING="2" CELLPADDING="1">
<TR WIDTH=100% HEIGHT=25>
<TD ALIGN=CENTER COLSPAN=3>
<IMG SRC=BANNER1.GIF>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER VALIGN=MIDDLE COLSPAN=3>
<H1>
YOU WANT MORE??
</H1>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER>
This is me and my younger brother.
</TD>
<TD ALIGN=CENTER>
<IMG SRC="siblings2.jpg">
</TD>
</TR>
</TABLE>
Problems: There were several issues with this HTML. First, the table is unbalanced. The first two rows each have three columns (due to the COLSPANS), but the last row only has two. Next, WIDTH and HEIGHT attributes are not allowed in TR tags (they must be put in TH and TD tags). While the use of an H1 tag within a TD tag is allowed, it seems less appropriate than using a TH tag rather than a TD tag. Finally, some of the values specified for attributes include special characters (periods and percent signs) so they should be quoted.Correction: <TABLE WIDTH="100%" BORDER=0 CELLSPACING="2" CELLPADDING="1"> <TR > <TD HEIGHT=25 ALIGN=CENTER COLSPAN=2> <IMG SRC="BANNER1.GIF"> </TD> </TR> <TR> <TH ALIGN=CENTER VALIGN=MIDDLE COLSPAN=2> YOU WANT MORE?? </TH> </TR> <TR> <TD ALIGN=CENTER> This is me and my younger brother. </TD> <TD ALIGN=CENTER> <IMG SRC="siblings2.jpg"> </TD> </TR> </TABLE>
For each layout, indicate whether it would be a possible topology for a token ring based network, an Ethernet, neither or both.
The two issues that lead to approximation in digital images and digital sound recording are the sampling rate and the sample accuracy. In the case of images, the sampling rate is just the number of pixels per inch. The more pixels per inch, the more accurate the representation can be. In each pixel, however, there is also another form of approximation related to how many digits (bits) of accuracy are used to represent the color of the pixel. The fewer digits used to represent colors, the more approximate each pixels color will be. Thus, 24-bit color is more accurate than 8 bit color.In the world of digital sound, the sampling rate is simply how many times per second the amplitude of the sound wave is measured. The sample accuracy is determined by the number of digits used to represent the amplitude at a given time. When discussing the phone system, I mentioned that 8 binary digits are used to represent the amplitude of each sample of the sounds sent through a phone call. Thus, only 256 different sound amplitudes can be represented exactly. Amplitudes that fall between these 256 values must be rounded (approximated) up or down.
The time that would be required for the token to travel all the way around the ring if it were never delayed by any computer on the way would be the total length of the ring, ND, divided by the speed of light.In the ring described, the token will be delayed at each computer along the way while the computer sends the data it has pending. Each computer will require (B/R) seconds to send its data, so the total amount added to the delay will be (N-1)B/R.
Accordingly, the maximum total delay will be:
(ND/c) + (N-1)B/R
While it decreases efficiency, restricting the maximum message size ensures that the ring is shared fairly when it gets busy. In particular, it ensures that there will be a guaranteed maximum amount of time a computer may have to wait before getting a chance to send a packet.
and the file "homeBut.gif" contains the familiar image:![]()
Examine the code shown and answer each of the questions following the code.
public class ActiveButton extends Controller
{
VisibleImage pic1;
VisibleImage pic2;
/* Specifies what to do when the applet first comes to life */
public void begin(){
pic1 = new VisibleImage(getImage("clickBut.gif"),0,0);
pic2 = new VisibleImage(getImage("homeBut.gif"),0,0);
}
/* Specifies how to react when the mouse button is depressed */
public void mouseDown() {
loadPage("http://www.cs.williams.edu/~cs105s00");
}
/* Specifies how to react when the mouse is moved into the applet's
screen window */
public void mouseEnter() {
pic2.hide();
}
/* Specifies how to react when the mouse is moved out of the applet's
screen window */
public void mouseExit() {
pic2.show();
}
}
The "clickBut" image will be visible when the mouse is within the image.
/* Specifies what to do when the applet first comes to life */
public void begin(){
pic2 = new VisibleImage(getImage("homeBut.gif"),0,0);
pic1 = new VisibleImage(getImage("clickBut.gif"),0,0);
}
With this change, the image that was on the bottom of the stack would be hidden when the mouse entered the image area rather than the image on top so no visible change would occur.