Assignment 3, due Feb 5

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

On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of lecture on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!

  1. Background: (A scavenger hunt question from the assigned readings.) Consider these two Java expressions: a&b and a&&b. (0.2 points each)

    a) In a&b, to what class (type) must a and b belong.

    b) In a&&b, to what class (type) must a and b belong.

    c) In a[i++]&b[i++] how many times is i incremented?

    d) In a[i++]&&b[i++] how many times is i incremented?

    e) What is similarity between the & and && operators that justifies using related symbols for them?

  2. A simple programming problem: Write a method to compute the Fibonacci function using the ?: operator in Java. Well formatted code for this function occupies about 3 lines of code — it is very compact but not very readable.

    As in the previous assignment, legible handwritten code is sufficient, but you can be more assured that it works if you try it on a computer. (1 point)

  3. Background: Suppose you were setting out to implement a neural network simulation, as described in the notes for January 25.

    a) Give Java code that captures all of the attributes of a neuron cell body. No methods are required, just the data attributes. (0.3 points)

    b) Give Java code that captures all of the attributes of an axon. Again, no methods are required, just the data attributes. (0.3 points)

    c) Give Java code that captures all of the attributes of a synapse. Again, no methods, just the data attributes. (0.3 points)

    d) Comment briefly on the correctness of this statement: There would be no loss of generality if axons and synapses were folded together into a single class combining the attributes of both. (0.1 points)