MONT 113G

    Home | | Course Schedule | | Assignments | | Lecture Notes

    Solutions to midterm review problems


    Problem 1: a) Convert to binary
    237 = 11101101
    45 = 00101101
    63 = 00111111

    Problem 2. Convert to hexadecimal
    237 = ED
    45 = 2D
    63 = 3F


    Problem 3: Convert to signed magnitude, 1's complement, and 2's complement:

    DecimalSigned magnitude1's complement2's complement
    22000101100001011000010110
    -31100111111110000011100001
    -22100101101110100111101010
    49001100010011000100110001


    Problem 4: Add the following two binary numbers:

    Binary Decimal
    01110001 113
    + 00011100 + 28
    = 10001101 = 141


    Problem 5: draw a circuit that computes the truth table:

    abc
    000
    011
    101
    110

    There are several possible solutions. The simplest uses an exclusive or (XOR) gate.

    Another possible solution uses AND and OR gates and Inverters.


    Problem 6: Write an expression for the output of the given circuit. Draw the truth table:

    Problem 7. Use the web page screen shot given in Figure 1 to answer the following questions. This shot was taken when the mouse was over the link.

    Figure 1. Screen shot of web page for problem 1

      a. What is the filename of the web page?

        Answer: mystery.html

      b. What is the title of the web page?

        Answer: Mystery Page

      c. Where does the link go?

        Answer: http://www.google.com

      d. What is the name of the web server that this page is served from?

        Answer: mathcs.holycross.edu

      e. Write the HTML file that would generate this page. Hint: Headlines of size 1 and 3 are in this page.

        Answer:
        <HTML>
          <HEAD>
            <TITLE>Mystery Page</TITLE>

          </HEAD>
          <BODY BGCOLOR = "white">

            <CENTER><H1>Hello World!</H1></CENTER>
            <P>
            <H3>Check out this magic <A HREF = "http://www.google.com">link</A></H3>

          </BODY>

        </HTML>

    Problem 8. The following equations give the running times (t) of different algorithms with respect to the size of the input (n). For each, state whether the problem is tractable or intractable:

      Answer:

    Problm 9. The following table gives the running time of an algorithm for different input sizes:

    	Size	time(secs)
    	1		0.5
    	2		2.0
    	3		4.5
    	4		8
    	5		12.5
    	...		...
    	10		50
    	100		5000
    

      a) Draw a graph of the running time vs. the input size for sizes of 1 to 5.

      b) Based on the values given, do you think this algorithm is tractable or intractable? Why?

      Answer: This algorithm appears tractable, because it can process an input the size of 100 in a relatively small amount of time (less than 1.5 hours). The actual running time here is about 1/2 (n*n) which is a polynomial so it is tractable.

    Problem 10. Protocols.

      a) What is the purpose of a protocol?

      Answer: A protocol is a set of rules that allow computers with different operating systems to communicate or exchange information.

      b) List three protocols that we covered in class, and briefly state their functions.

      Answer: 1) TCP: Transmission control protocol--breaks email into packets at source computer and puts message back together at destination.

      2) IP: Internet protocol--routes email across internet.

      3) HTTP: Hypertext Transfer Protocol--transfer web pages and associated files.

      4) FTP: File Transfer protocol--transfer files from one computer to another.

    Problem 11. What color does #FF00FF represent in the RGB color representation?

    Answer: Purple

    Problem 12. Suppose an image file has a bit depth of 8, a width of 100 pixels and a height of 200 pixels.

      a) How many colors are can be represented in the image?

      Answer: 256 (that is, 2 to the 8th power).

      b) What is the size of the image if displayed on a monitor with a resolution of 50 ppi (pixels per inch)?

      Answer: 2 inches in width by 4 inches in height.

    Problem 13. Briefly describe what "packet switching" means and how it is used on the internet.

    Answer: Packet switching is the process in which email messages are broken up into small "packets". Each packet is sent separately across the internet (and they may take separate routes to their destination).

    Problem 14. What is a non-computable function? Describe 2 problems that are non-computable.

    Answer: A non-computable function is one for which no computer program can be written that will solve the function.

    Two problems that are non-computable are:

    • The Halting Problem: Determining whether a program will halt in a finite amount of time.
    • Determining whether two programs are equivalent (for each input they both give the same output.)

    Problem 15. Suppose you want to prove that a given problem was non-computable with a proof by contradiction. What are the 2 steps you must accomplish for such a proof?

    Answer: 1)Assume the program to solve the problem exists.

    2) Show that this assumption leads to impossible consequences.

    Problem 16. Write an assembly language (P88 instructions) to read in two numbers. If the first is bigger, it should print out the first number. Otherwise the program should print nothing and end.

    Answer:

      		IN AX
      		COPY X, AX
      		IN AX
      		CMP AX, X
      		JNB LAST
      		COPY AX, X
      		OUT AX
      	LAST	END