Assignment 1 Solutions

Due Jan 18 in discussion section

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

  1. A test of your understanding of the prerequisites: Consider this recursive integer function. All operators here are integer operations. This is an informal mathematical definition; it is not coded in a programming language:

    if i < 2, f( i ) = i + 1
    otherwise f( i ) = f( i – 1 ) × f( i – 2 )

    A Question: Give the values of f(0) through f(9). (1.0 point)

    if( i )
    0 1 = 0 + 1
    1 2 = 1 + 1
    2 2 = f( 1 ) × f( 0 ) = 2 × 1
    3 4 = f( 2 ) × f( 1 ) = 2 × 2
    4 8 = f( 3 ) × f( 2 ) = 4 × 2
    5 32 = f( 4 ) × f( 3 ) = 8 × 4
    6 256 = f( 5 ) × f( 4 ) = 32 × 8
    7 8192 = f( 6 ) × f( 5 ) = 256 × 32
    8 2097152 = f( 7 ) × f( 6 ) = 8192 × 256
    9 17179869184 = f( 7 ) × f( 6 ) = 2097152 × 8192

  2. Background: In the introduction to the Eckel's textbook, he describes the coding style he uses.

    A question: How does (or does not) the Java compiler enforce use of this coding style? This is a scavenger hunt question to get you to look at the text. Note, the free download of chapters 1-7 means you can get this answer without spending any money.

    The compiler does not enforce a coding style.

  3. Background: If you do not have a CLAS Linux account, create one. The instructions are here:
      — http://clas.uiowa.edu/linux/help/fastx
    Follow the instructions there.

    Use your account to sign in using FastX. The following link takes you to FastX:
      — http://fastx.divms.uiowa.edu
    FastX opens a remote Linux desktop. The MATE desktop has an icon at the top to let you open a command line shell interface in the a terminal window.

    When it is time to end your session, the exit shell command will close your terminal window. To close your FastX session and log out of Linux, click on the LogOut button in the System pull-down menu on your Linux desktop.

    For more information, see:
      — http://clas.uiowa.edu/linux

    A question: Use a shell window on a CLAS Linux machine. Type the following command:
      [HawkID@fastx02 ~]$ ~dwjones/object
    (Boldface in the above is the command you type, non-bold is the prompt from the system; type the requested text verbatim, do not change a thing.) Report the output you got. If you did not make it all the way to the point where you could do the above, report how far you got. (1 point)

    Time will be provided in the discussion section to help those who have trouble with this. The rest of time will be spent demonstrating and inviting you to play with the Java hello-world program on the CLAS Linux system.

    Here is what it output for me. Your answer will differ depending on what your HawkID is and what time you run the command:

    [dwjones@fastx01 ~]$ ~dwjones/object
    On Fri Jan 18 09:51:05 CST 2019, dwjones did CS:2820 assignment 1 problem 3.