 |
CS 112 - Introduction to Computer Science II
Homework #1 |
Assignment work will be individual for this assignment only. Due:
Friday 1/26 at the beginning of class 3.
Include a README file with the honor pledge, your name and student ID, and
written exercises. We will cover the submission process in class.
Be sure to have your README and ModularPascalsTriangle.java in the same default package directory. 1. Bash: Have you already learned the
basics of the bash shell as represented in our
tutorial?
-
Yes: Consult online documentation, learn three new things about the bash
shell, and describe them briefly. Include these descriptions in your
README file.
-
No: Do the bash tutorial ("Getting
started with bash at Gettysburg"). Do
the tutorial in one sitting so that you'll be able to submit a transcript
of your shell commands. These will be appended to a "README" file which
can be submitted via Moodle.
2. Eclipse: (Optional: Watch the
Deitel Eclipse
introduction video. This can be viewed on non-Linux campus computers.) In
class: Do the Eclipse tutorial "Create
a Hello World application". Get to the Welcome screen either at first
startup or via Help→Welcome. Choose "Tutorials".
Under "Java Development", choose "Create
a Hello World application". Follow the tutorial instructions step-by-step in
the "Welcome" tab in the right margin. Since we'll be doing this
in class, there will be nothing you'll need to submit; your attendance and
participation will give you full credit.
The more you know of your work
environment, the more efficient you will be. A little time spent above and
beyond these tutorials will likely pay off significantly in the long run as a CS
major/minor.3. Modular Pascal's Triangle: Read about
Pascal's Triangle.
For this exercise, you will be computing a 2D array with a Modular Pascal's
Triangle, that is, a Pascal's Triangle formed with
modular addition.
(This will be similar in arrangement to the last Fibonacci pattern figure of
this
Wikipedia article section, with blank areas filled with 0's.) Implement and submit ModularPascalsTriangle.java according to
this specification.
Optionally, here's some fun you can have while testing your program:
- You may visualize the beautiful patterns formed by your code using
ModularPascalsTrianglePlot.java. For modulus 2, you'll see the
Sierpinski
triangle pattern. This needs to be compiled in the same directory
as your ModularPascalsTriangle.java and should be run from the command
prompt as follows: "java ModularPascalsTrianglePlot <size> <mod>" where the
<size> is the number of rows and the number of columns. E.g.
"java ModularPascalsTrianglePlot 400 5". Zeros are colored white and
from 1 to the modulus minus 1 fades from red to yellow to green to blue.
- For any prime modulus, what do you observe about the patterns? Try
2, 3, 5, 7, 11, and 107 for different sizes.
- For these prime modulus plots, what do you observe at the top of each of the
white (zero) downward triangles?
- For larger prime modulus plots (e.g. 997, 104729), what do you observe within
the non-white (non-zero) regions?
- For simple non-primes (e.g. 6), do you observe any interesting patterns?
Rubric: (20 points total)
- 6 points: Bash
- tutorial path:
- all tutorial commands executed and evidenced in the README file
output of history command: full credit
- for every 3 tutorial commands missed, -1 point
- learn three new things (not in tutorial):
- for each piece of new bash knowledge described that is not
in the
tutorial, +2 points (up to 6 points maximum)
- 4 points: Eclipse
(awarded according to attendance records for class 1)
- 10 points: Modular Pascal's Triangle