Skip to main content

SOLUTIONS MANUAL for A Balanced Introduction to Computer Science, 3 Edition David Reed

Page 1

A Balanced Introduction to Computer Science, 3 Edition David Reed NOTE: CHAPTER 2 IS NOT AVAILABLE Chapter 1 Review Question Solutions

1.

TRUE or FALSE? In order to be classified as a "computer," a device must have a keyboard and display screen. FALSE

2.

TRUE or FALSE? A bus is a collection of wires that carry information as electrical signals between the hardware components of a computer. TRUE

3.

TRUE or FALSE? As computer programs can be complex and difficult to write, they are known as "hardware." FALSE

4.

TRUE or FALSE? A bit is a unit of data that correspond to one of two potential values (commonly written as 0 and 1). TRUE

5.

TRUE or FALSE? A kilobyte of storage is 210 = 1,024 bytes, where a byte is a collection of eight bits. TRUE

6.

TRUE or FALSE? A hard disk is classified as volatile memory, because it requires a constant power supply in order to retain its information. FALSE

7. TRUE or FALSE? Keyboards and mice are examples of computer input devices. TRUE 8.

TRUE or FALSE? A directory is a collection of files that are organized together and labeled with a common name.

1.1


TRUE 9.

TRUE or FALSE? The World Wide Web was developed in the early 1970's, shortly after the creation of the Internet. FALSE

10. TRUE or FALSE? A Web browser is an example of applications software. TRUE 11. Describe the difference between hardware and software and identify two examples of each type. The term hardware refers to the physical components of the computer, such as the monitor, keyboard, hard drive, etc. Software refers to the programs that execute (i.e., run) on the computer, carrying out tasks such as word processing or accessing the Web. 12. Describe the three essential components of a computer that make up the von Neumann architecture. How do these components work together to produce a machine that can be programmed to complete different tasks? Input/Output devices allow the user to communicate with the computer by entering commands and then viewing the results. Memory stores information for the computer to process, as well as programs, or instructions specifying the steps necessary to complete specific tasks. Finally, the Central Processing Unit (CPU) is the component that carries out programmatic steps in order to process data. 13. Modern computers integrate several different types of memory, such as cache, RAM, hard disk, and floppy disk. Why are different types of memory used, as opposed to the exclusive use of a particular technology? What would be the drawbacks, for example, of using only cache memory, or only hard disk? Different types of memory have different characteristics with respect to cost and volatility. Main memory (cache and RAM) is fast, and so is used for data that is currently being accessed. However, cache and RAM are too expensive for mass storage, and they are volatile (requiring a constant flow of electricity to maintain stored values). Secondary memory (hard disk, floppy disk, etc.) is much cheaper and permanent, but also much slower than cache and RAM. However, it is sufficient for storing data that is not currently needed. 14. Computer memory is usually grouped in bytes, which consist of 8 bits each. How many different values can be represented using a byte? How many different values can be represented using two bytes?

1.2


One byte (8 bits) can represent 28 = 256 different values. Two bytes (16 bits) can represent 216 = 65,536 different values. 15. The Intel Core 2 Duo is an example of a processor, or CPU, as are the Celeron and PowerPC. List the two main tasks that the CPU performs in controlling the computer’s workings and provide a short explanation of each. The CPU is responsible for two key tasks: (1) fetching program instructions from memory, and (2) executing those instructions. 16. In what units are CPU speeds measured, and what does this measurement unit refer to? If one computer has a 2 GHz Celeron D processor and another has a 2 GHz PowerPC processor, does that imply they will be able to execute the same program in the same amount of time? Explain. CPU speed is generally measured in gigahertz (GHz), which indicates how many billions of basic instructions a CPU can execute in a second. For example, a 2 GHz CPU can execute approximately 2 billion instructions in a second. Since different families of CPUs will provide different basic operations, performance comparisons based on CPU speed are not always accurate. 17. Windows 7 is an example of an operating system, as are the Mac OS and Linux. List the three main tasks that the operating system performs in controlling the computer’s resources and behavior. Provide a short explanation of each. The most fundamental task performed by the operating system is to schedule the operation of the CPU, controlling how data and instructions are loaded from memory and accessed by the CPU. The operating system also manages the memory of the computer, organizing storage into files and directories (or folders). Finally, the operating system connects the CPU and memory with the other hardware components of the computer, allowing software applications to access memory and interact with the input/output devices. 18. Describe three elements common to a Graphical User Interface (GUI)? How do these elements make it easier for a user to interact with the computer. A GUI utilizes intuitive, visual elements to simplify the process of viewing files and executing programs. Programs, directories and files are represented as icons, or small pictures that convey some aspect of the element they symbolize. Windows represent separate workspaces that can be active at the same time, displaying files or executing programs. Most GUIs also utilize pull-down menus of commands, which allow the user to identify and select common commands easily.

1.3


19. Suppose you are shopping for a personal computer that you plan to use exclusively for email and Web access. Which would be a better use of your limited funds – a faster CPU or a larger hard drive? Why? Since sending email and accessing the Web do not require extensive computation, blazing speed is not necessary in a CPU. Most of the time, the CPU will be idle while you are typing an email, or reading a message or Web page. On the other hand, if you are going to be storing a large number of messages and downloading files off the Web, lots of hard drive space might prove useful. 20. It has been said that the Internet could exist without the Web, but the Web couldn't exist without the Internet. Why is this true? The Internet is a vast, international network of computers, which existed more than 20 years before the World Wide Web. Many networking applications are supported by the Internet, such as email, instant messaging, ftp (file transfer), and the Web. The Web is a collection of software that spans the Internet and enables the interlinking of documents and resources. 21. What is a Web server, and what role does it play in the World Wide Web? A Web server is an Internet-enabled computer that executes software for providing access to Web documents. When the server receives a request for a particular page from a Web browser, it locates the specified page in its directories and sends the page back to the browser via the Internet. 22. Consider the following fictional URL: http://www.acme.com/products/info.html. What does each part of this URL (separated by slashes) specify? http://, specifies that the HyperText Transfer Protocol should be used in communications between the browser and server. www.acme.com identifies the Web server that stores the page. products is a directory on that server, and info.html is the

name of the file stored in that directory.

1.4


A Balanced Introduction to Computer Science, 3/ E David Reed . Chapter 3 Review Question Solutions

1. TRUE or FALSE? The ARPANet, the precursor to today’s Internet, was funded primarily by the U.S. Department of Defense. TRUE 2. TRUE or FALSE? Because the ARPANet utilized ordinary phone lines to connect computers over large distances, it was slow compared to existing technologies of the time. FALSE 3. TRUE or FALSE? In a centralized computer network, the failure of a single machine or connection can isolate large portions of the network. TRUE 4. TRUE or FALSE? A router is a special-purpose computer on the Internet that receives message packets, access routing information, and passes the packets on towards their destination. TRUE 5. TRUE or FALSE? When a message is broken into packets as transmitted over the Internet, it is guaranteed that all packets will take the same route from source to destination. FALSE 6. TRUE or FALSE? 147.134.2.84 is an example of an IP address. TRUE 7. The Internet Society, an international non-profit organization, maintains and enforces standards for the hardware and software of the Internet. TRUE

3.1


8. TRUE or FALSE? The World Wide Web was developed in the early 1970s, shortly after the development of the Internet. FALSE 9. TRUE or FALSE? Microsoft marketed the first commercial Web browser. FALSE 10. TRUE or FALSE? In the URL http://balance3e.com/index.html, the part balance3e.com identifies the Web server where the page is stored. TRUE 11. The Internet of today evolved from the ARPANet of the 1960s and 70s. In what ways is the Internet similar to the old ARPANet? In what ways is it different? Following the initial design of the ARPANet, the Internet is a distributed network that utilizes packet-switching. However, the number of users and variety of uses for the Internet has far exceeded any expectations of the ARPANet, which was designed for use by a small number of military researchers. To accommodate the large number of computers on the Internet, it has evolved into a hierarchical network, with high-speed backbones for transmission between central locations and slower communication lines for local connections. 12. The Internet is often described as the "Information Superhighway." Describe how the analogy of a highway system fits the structure of the Internet. The backbone connections are analogous to interstate highways, providing fast communications between principal destinations. Connected to the backbone are transmission lines, which provided slower, more limited capabilities and linked secondary destinations; these transmission lines could be compared to state highways. Additional connections are required to reach individual computers, in the same way that city and neighborhood roads are used to link individual houses. 13. Paul Baran proposed two groundbreaking design ideas for the structure and behavior of the ARPANet. Describe these design ideas and the benefits they provide. The first of Baran’s ideas adopted for the ARPANet was that of a distributed network, where control is distributed across a large number of machines. This allows for messages to be rerouted along alternate connections when a particular computer or connection fails. Baran’s other idea central to the ARPANet architecture was that of packet-switching, where messages to be sent over the network are first broken into small pieces and then sent independently to their final destination. Advantages of this approach

3.2


include a more efficient use of the connections, the ability to react to failures and congestion, and improved reliability. 14. Describe how packet-switching can increase the reliability of a network. In a packet-switching network, messages to be sent over the network are first broken into small pieces known as packets, and these packets are sent independently to their final destination. If a message is broken into packets and the packets are transmitted independently, it is probable that at least part of the message will arrive at its destination, even if some failures occur within the network. If the recipient receives only part of the message, TCP software on his or her computer can acknowledge the partial message’s receipt and request retransmission from the sender. 15. Internet communications are defined by a set of protocols called TCP/IP. What do TCP and IP stand for, and what is the role of each protocol in transmitting and receiving information? Transmission Control Protocol (TCP) controls the method by which messages are broken down into packets and then reassembled when they reach their final destination. Internet Protocol (IP), on the other hand, is concerned with labeling the packets for delivery and controlling the packets’ paths from sender to recipient. 16. What is an IP address? What steps are involved in mapping a computer's domain name (e.g., www.creighton.edu) to its IP address? An IP address is a number, usually written as a dotted sequence such as 147.134.2.84. Special-purpose computers called domain name servers are used to store mappings between domain names and their corresponding IP addresses. When a computer sends a message to a destination such as www.creighton.edu, the sending computer first transmits a request to a domain name server, which matches the recipient’s domain name to an IP address and returns that address. 17. Which has grown at a faster rate, the Internet or the Web? Justify your answer. The data in Figure 3.15 gives somewhat mixed results. If you look at the period from 2006 to 2010, the Web has grown at a faster rate, with the number of Web servers increasing by 133% compared with a 72% increase in Internet-connected computers. Most recently, from 2008 to 2010, the number of Web servers has increased at a smaller rate: 17% versus 33%. If you judge Web size by the number of pages, then the Web is growing much faster (from 8 billion pages in 2005 to 40 billion pages in 2009). 18. What is hypertext? How are the key ideas of hypertext incorporated into the Web?

3.3


The term hypertext refers to documents that interlink text and media, such as images, sounds, and alternate story lines. The Web utilizes hypertext in that Web pages can contain other media and links to other pages as well. 19. What specific features did the Mosaic browser include that were not available in earlier browsers? How did these features help make the Web accessible to a larger audience? Mosaic employed buttons and clickable links as navigational aids, making the Web easier to traverse. The browser also supported the integration of images and media within pages, which enabled developers to create more visually appealing Web documents. 20. Describe two factors that contributed to Microsoft’s dominance of the browser market. Microsoft’s financial position was much stronger than Netscape’s — due to its success with other software products, Microsoft possessed vast resources with which to develop and market its browsers. Also, Microsoft was able to leverage its dominance in operating systems by packaging Internet Explorer as part of Windows. 21. What does HTTP stand for, and what is its role in facilitating Web communications? HyperText Transfer Protocol (HTTP) is the protocol that determines how messages exchanged between browsers and servers are formatted. 22. The World Wide Web Consortium maintains and regulates Web-related standards and oversees the design of Web-based technologies. Visit their Web site (www.w3.org) to review the organization’s goals and list of technologies under active development. Describe three technologies (other than HTML, HTTP, and XML) whose development is managed by the World Wide Web Consortium. Student answers will vary. 23. How does caching improve the performance of a Web browser? Does caching reduce the number of interactions that take place between the browser and the Web server? When a page or image is first downloaded, it is stored in a temporary directory on the user's computer. The next time that page or image is requested, the browser first checks to see if it has a copy stored locally in the cache, and, if so, whether the copy is up-to-date (this is accomplished by contacting the server and asking how recently the page was changed). If an up-to-date copy is stored locally, then the browser can display this copy, instead of downloading the original. Caching can make downloading a new copy unnecessary, but it still requires a check to see if the cached page is up-to-date.

3.4


A Balanced Introduction to Computer Science, 3/E David Reed . Chapter 4 Exercise Solutions

EXERCISE 4.1:

Enter the mystery1.html text from Figure 4.1 into a new Web page, then load the page in the browser to verify that it behaves as described. Modify the page so that it uses any two images that you choose. These may be images located on the Web (specified by an absolute URL starting with http://) or local images that you have downloaded to your own machine (specified by a relative URL without http://). <!doctype html> <!-- mystery1.html Dave Reed --> <!-- This page changes an image source on mouseover. --> <!-- =============================================== --> <html> <head> <title>Mystery Image</title> </head> <body> <div style="text-align:center"> <img src="http://balance3e.com/Images/mystery.gif" alt="Mystery image" onmouseover="this.src='http://images.despair.com/products/demotivators'+ '/motivation.jpg';" onmouseout="this.src='http://balance3e.com/Images/mystery.gif';"> <p> Move the mouse over the question mark to reveal the image. </p> </div> </body> </html>

EXERCISE 4.2:

Similar to the mystery1.html page, create a Web page named resize1.html that contains a dynamic, resizable image. The ONMOUSEOVER attribute of that image should contain JavaScript assignments that set the height and width to twice that of the original dimensions. That is, if the image dimensions are 71x55 pixels, then moving the mouse over the image should result in the image expanding to 142x110. Conversely, the ONMOUSEOUT attribute should contain JavaScript assignments that reset the height and width back to the original dimensions of the image. <!doctype html> <!-- resize1.html Dave Reed --> <!-- This page changes an image size on mouseover. --> <!-- ================================================= --> <html> <head> <title>Mouse Over</title> </head>

4.1


<body> <div style="text-align:center"> <img id="mysteryImg" src="http://balance3e.com/Images/happy.gif" height=85 width=85 onmouseover="this.height=200; this.width=200" onmouseout="this.height=85; this.width=85"> <p> Move the mouse over the face to expand it. </p> </div> </body> </html>

EXERCISE 4.3: Enter the mystery2.html text from Figure 4.4 into a new Web page, then load the page in the browser to verify that it behaves as described. Modify the page so that it uses the same two images that you chose for your mystery1.html page (from Exercise 4.1). <!doctype html> <!-- mystery2.html Dave Reed --> <!-- This page changes an image source on a click. --> <!-- ============================================= --> <html> <head> <title> Mystery Image</title> </head> <body> <div style="text-align:center"> <img src="http://balance3e.com/Images/mystery.gif" alt="Mystery Image" onclick="this.src='http://images.despair.com/products/demotivators'+ '/motivation.jpg';"> <p> Click on the question mark to reveal the image. </p> </div> </body> </html>

EXERCISE 4.4 EEnter the mystery3.html text from Figure 4.6 into a new Web page, then load the page in the browser to verify that it behaves as described. Modify the page so that it uses the same two images that you chose for your mystery1.html page (from Exercise 4.1). <!doctype html> <!-- mystery3.html Dave Reed --> <!-- This page changes an image source on button clicks. --> <!-- =================================================== --> <html> <head> <title>Mystery Image</title> </head> <body> <div style="text-align:center">

4.2


<img id="mysteryImg" src="http://balance3e.com/Images/mystery.gif"> <p> <input type="button" value="Show Image" onclick="document.getElementById('mysteryImg').src= 'http://images.despair.com/products/demotivators'+ '/motivation.jpg';"> <input type="button" value="Hide Image" onclick="document.getElementById('mysteryImg').src= 'http://balance3e.com/Images/mystery.gif';"> </p> </div> </body> </html>

EXERCISE 4.5 Modify the mystery3.html page so that it acts as a simple slide show. You should add at least three more buttons, each associated with a different image. As before, these may be images located on the Web (specified by an absolute URL starting with http://) or local images that you have downloaded to your own machine (specified by a relative URL without http://). Be sure that the label on each button clearly identifies the image that is displayed at the click of that button. <!doctype html> <!-- slides.html Dave Reed --> <!-- This page changes an image source on button clicks. --> <!-- =================================================== --> <html> <head> <title>Demotivational Slideshow</title> </head> <body> <div style="text-align:center"> <img id="mysteryImg" src="http://balance3e.com/Images/mystery.gif"> <p> <input type="button" value="Ambition" onclick="document.getElementById('mysteryImg').src= 'http://images.despair.com/products/demotivators'+ '/ambition.jpg';"> <input type="button" value="Motivation" onclick="document.getElementById('mysteryImg').src= 'http://images.despair.com/products/demotivators'+ '/motivation.jpg';"> <input type="button" value="Pretension" onclick="document.getElementById('mysteryImg').src= 'http://images.despair.com/products/demotivators'+ '/pretension.jpg';"> <input type="button" value="Success" onclick="document.getElementById('mysteryImg').src= 'http://images.despair.com/products/demotivators'+ '/success.jpg';"> <input type="button" value="Wishes" onclick="document.getElementById('mysteryImg').src= 'http://images.despair.com/products/demotivators'+ '/wishes.jpg';"> </p> </div> </body> </html>

4.3


EXERCISE 4.6 Create a variant of the resize1.html page from Exercise 4.2 named resize2.html. This page should contain an image and two buttons, labeled "Expand Image" and "Restore Image." When the "Expand Image" button is clicked, the height and width of the image should be set to large values (e.g., 200 x 200). Likewise, when the "Restore Image" button is clicked, the height and width should be reset to their original values (e.g., 85 x 85). <!doctype html> <!-- resize2.html Dave Reed --> <!-- This page changes an image size on button clicks. --> <!-- ================================================= --> <html> <head> <title>Image Resizer</title> </head> <body> <div style="text-align:center"> <img id="testImg" height=85 width=85 src="http://images.despair.com/products/demotivators/motivation.jpg"> <p> <input type="button" value="Enlarge" onclick="document.getElementById('testImg').height=200; document.getElementById('testImg').width=200;"> <input type="button" value="Shrink" onclick="document.getElementById('testImg').height=85; document.getElementById('testImg').width=85;"> </p> </div> </body> </html>

EXERCISE 4.7 Create a Web page named alert.html that contains a button. When clicked, the button should pop up an alert window that displays some message. The content of the message is entirely up to you. <!doctype html> <!-- alert.html Dave Reed --> <!-- This page changes opens an alert window on a button click. --> <!-- ========================================================== --> <html> <head> <title>Alert Page</title> </head> <body> <input type="button" value="Click for free money!" onclick="alert('Yeah, right.');"> </body> </html>

EXERCISE 4.8 Enter the help.html text from Figure 4.10 into a new Web page, then load the page in the browser to verify that it behaves as described.

4.4


Modify the page so that it has an additional button labeled "Clear Help." When clicked, the INNERHTML attribute of the outputDiv page division should be reassigned so that the original text ("Welcome to my site!") is displayed. <!doctype html> <!-- help.html Dave Reed --> <!-- Web page that displays a help message when a button is clicked. --> <!-- =============================================================== --> <html> <head> <title>Button Help</title> </head> <body> <p> Contents of the page. </p> <input type="button" value="Click for help" onclick="document.getElementById('outputDiv').innerHTML= 'If you have any trouble with this site, ' + 'contact <i>admin@foo.bar</i>.';"> <input type="button" value="Clear help" onclick="document.getElementById('outputDiv').innerHTML= 'Welcome to my site!';"> <hr> <div id="outputDiv"> Welcome to my site! </div> </body> </html>

EXERCISE 4.9 An alternative to using buttons to display and hide help messages in a page would be to have dynamic help icons within the page. By moving the mouse over a help icon, the user could see the message associated with that icon. Create a page named help2.html that contains a help icon at the bottom left (as in Figure 4.13). You may use the http://balance3e.com/Images/help.jpg image for your icon, or use your own image if you prefer. When the mouse moves over the icon, a help message should be displayed in a page division to the right of the icon (Figure 4.14). When the mouse moves off the icon, the page division should be cleared. Hint: to position the text to the right of the image, consider embedding the image and page division in a table (similar to the demo11.html page from Figure 2.21). <!doctype html> <!-- help2.html Dave Reed --> <!-- Web page that displays a help message when a button is clicked. --> <!-- =============================================================== --> <html> <head> <title>Image Help</title> </head> <body> <p> Contents of the page. </p> <hr>

4.5


<table> <tr> <td><img src="http://balance3e.com/Images/help.jpg" onmouseover="document.getElementById('outputDiv').innerHTML= 'If you have any trouble with this site, contact ' + '<i>admin@foo.bar</i>.';" onmouseout="document.getElementById('outputDiv').innerHTML='';"> </td> <td> <div id="outputDiv"></div> </td> </tr> </table> </body> </html>

EXERCISE 4.10 Create a Web page named quotes.html that can be used to select and display at least three of your favorites quotations. The layout of this page is up to you. In particular, you may choose to use buttons or dynamic images, as shown in Figures 4.15 and 4.16, respectively. The button or image should clearly identify the author of the quotation, and the author's name should appear in italics at the end of the quotation. <!doctype html> <!-- quotes.html Dave Reed --> <!-- Web page that displays quotes at the click of a button click. --> <!-- ============================================================= --> <html> <head> <title>Quote Page</title> </head> <body> <div style="text-align:center"> <h2>Computing Quotes</h2> <input type="button" value="Alan Turing" onclick="document.getElementById('outputDiv').innerHTML= 'I believe that at the end of the century the use of words and general ' + 'educated opinion will have altered so much that one will be able to ' + 'speak of machines thinking without expecting to be contradicted. ' + '-- <i>Alan Turing</i>';"> <input type="button" value="John von Neumann" onclick="document.getElementById('outputDiv').innerHTML= 'It would appear that we have reached the limits of what it is ' + 'possible to achieve with computer technology, although one should ' + 'be careful with such statements, as they tend to sound pretty silly ' + 'in 5 years. -- <i>John von Neumann</i>';"> <input type="button" value="Tim Berners-Lee" onclick="document.getElementById('outputDiv').innerHTML= 'Anyone who has lost track of time when using a computer knows the ' + 'propensity to dream, the urge to make dreams come true and the ' + 'tendency to miss lunch. -- <i>Tim Berners-Lee</i>';"> </div> <hr> <div id="outputDiv"></div> </body> </html>

<!doctype html> <!-- quotes.html Dave Reed --> <!-- Web page that displays quotes at the click of a button click. --> <!-- ============================================================= -->

4.6


Turn static files into dynamic content formats.

Create a flipbook
SOLUTIONS MANUAL for A Balanced Introduction to Computer Science, 3 Edition David Reed by digitaldownload87 - Issuu