Assignment 2, due Jan 25

Part of the homework for CS:2820, Spring 2019
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Assignments are to be turned in on paper. On every assignment, write your name, course and section number at the top of each page. Write your name as it appears in your university records! Use the section number for which you are registered! We will not do detective work to figure out who did what. Work must be legible.

Homework is due on paper in discussion section, usually at the start except when the assignment indicates that time to work on the assignment will be provided in class. Exceptions will be made only by advance arrangement with your TA (excepting "acts of God" outside your control). Never push homework under someone's door!

  1. Background: Consider these two Java declarations:

    int x = 1;
    char y = (char)('b' + x);
    String z = (String)("b" + y);
    

    (Why the type casting (the (char) and (string))? The Java wants one of them, the other was included to make the code more symmetrical.)

    a) What operation does the + operator do in computing the value of y. (0.3 points)

    b) What is the resulting value of y? (0.2 points)

    c) What operation does the + operator do in computing the value of z. (0.3 points)

    d) What is the resulting value of z? (0.2 points)

  2. Background: In the notes for Lecture 5, there is a table of the 16 Boolean functions of 2 variables. If you read the row labels in this table as binary numbers, then function number 1 is and, function 7 is or, and function 14 is nand.

    a) Give the truth table for the 2-input function called b or not a. (0.3 points)

    b) What is the above function's number in the table of 16 functions. (0.2 points)

    c) Give the truth table for the 2-input function called b and not a. (0.3 points)

    d) What is the above function's number in the table of 16 functions. (0.2 points)

  3. Background: In lecture 4, we propose to model a road network using one-way roads between intersections. Once a vehicle enters a road, it is required to follow that road to the next intersection. All manuvering required by our model must therefore take place at intersections, so we must introduce intersections at each point where a driveway enters or exits the road network, and if we model each lane as a separate road, then if we want to model lane changes in midblock, we must introduce an intersection at that point.

    Consider the problem of modeling the city block bounded by Iowa Avenue, Dubuque, Washington and Clinton streets (east across the street from the Pentacrest). with these streets if we ignore the complexity of the bus interchange:

    Do not include any streets (or alleys) in your answer that lead away from the block in question, but do include the intersections to which they connect and do include the alley that leads to the interior of the block. Note that every vehicle that enters this alley must eventually come back out, but that it may stay inside the block for a long time if it parks behind one of the businesses on the block.

    A problem: Draw a diagram, with points for every intersection and arrows connecting the points for "road" to show how this road network would be modeled. The arrow head on each "road" indicates the direction of travel on that road.

    Legibility matters. Lay out your diagram with north on the top and try to keep the topology the same as the real road network. Exact scale does not matter, but You might start by using a blow-up of a map as a layout guide (there are plenty of on-line map services). If your drawing skills are horrible, you may have to redraw a few times to get legible results.