MONT 113G
Home | | Course Schedule | | Assignments | | Lecture NotesSolutions 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:
Decimal | Signed magnitude | 1's complement | 2's complement |
22 | 00010110 | 00010110 | 00010110 |
-31 | 10011111 | 11100000 | 11100001 |
-22 | 10010110 | 11101001 | 11101010 |
49 | 00110001 | 00110001 | 00110001 |
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:
a | b | c |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
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
b. What is the title of the web page?
c. Where does the link go?
d. What is the name of the web server that this page is served from?
e. Write the HTML file that would generate this page. Hint: Headlines of size 1 and 3 are in this page.
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:
Size time(secs) 1 0.5 2 2.0 3 4.5 4 8 5 12.5 ... ... 10 50 100 5000
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.
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.
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:
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