






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







CMSC 132 Spring 2006 Midterm 2 Answers Problem 1 Hashing/Other (12 pts)
Problem 2 Networking (12 pts)
1. (3 pts) Does HTTP use UDP or TCP? Answer : TCP 2. (3 pts) Say you have two computers on the network (machines A and B). Machine A needs to send a short, 4-byte message to machine B, and doesn’t expect to see any message in response. Discuss the merits of using TCP vs. UDP for this communication. Answer : UDP will give fast performance and less overhead, but TCP will give A confirmation that B received the message. 3. (3 pts) Give the first line of a request that a web browser might send to the CNN web server (using the HTTP protocol) to display the page http://www.cnn.com/index.html Answer: GET /index.html HTTP/1. 4. (3 pts) What is the task performed by the accept method of the Java ServerSocket class? Answer: wait until a client connects, and then create a Socket for two-way TCP communication with that client.
Problem 4 Algorithmic Complexity (12 pts)
Problem 5 Regular Expressions (10 pts)
Problem 7 Linear Data Structures (12 pts)
Problem 8 Maps/Sets (12 pts) Consider the following class. The main method is primarily provided to ensure that you understand how mapWords will be called; you can probably understand and answer the question without looking at the main method, but it is provided as a backup/auxiliary explanation. public class MapWords { public static void main(String[] args) throws IOException { Map<String, Set
} For example, when run on the input: a b c d e f a d f The class might generate the output {d=[2, 3], a=[1, 3], c=[1], f=[2, 3], b=[1], e=[2]}
Honor Section (10 pts)