Course Page for 22C:021, A04 and A05
Greg Nichols' Page (office hours and the like)
Official Course Page
Zhihong's CS2 course page (notes/code from her TA sessions, useful stuff)
Dr. Sriram Pemmaraju's Page
This page will contain useful (or not) information about the discussion sections I lead. Or at least
some synopsis.
Stuff we did in class...
August 31, September 2:
Went over some basic stuff about the Vector class. Wrote some spiffy code that implemented a remove
method (that, given a value, found and removed the first instance of that value). Modified it to
remove all instances of that element instead of just the first. Discussed why that's an inefficient
solution - O(n2) - and went over a new algorithm that does the same thing, in O(n) time.
September 7, 9:
Went over the Matrix class (the author's Matrix class, that is...), its methods, and the way it is
implemented (using the Vector class).
September 14, 16:
Went over the project that was just assigned, the SparseMatrix class... its interface, how it is
supposed to be implemented, that sort of thing. Went over a couple of problems you may run into and
things you may not know how to do... code execution timing, using primitive types - int's, mainly -
with containers that expect Object types, random number generation, the meaning of life, and so on.
September 21, 23:
Discussed how to take Project 1 and break it up into smaller, more easily doable pieces. Went over a
couple of 'utility functions' that dump out the current contents of the matrix in a few different forms
that will make debugging quite a lot easier.
September 28, 30:
Went over the basics of recursion: how it works, what it's good for, how to
use it, etc.
October 5, 7:
No discussion sections this week.
How to compile and run Java programs in Linux:
- Make sure you have a CS account, and get yourself logged into a Linux server. (Don't have a Unix
account? You should. Not sure what to tell you; ask Dr.
Pemmaraju about how to get one.)
- Edit your Java source file (just a plain text file). You can either edit it directly on your own
computer and sftp or scp it to the Linux server (linux.cs.uiowa.edu), or just use a text editor. If
you're in a lab most any text editor you can find will work. If you're connected remotely via ssh, and
you don't already have a preferred editor, try something simple like nano.
- Compile your programs using javac:
javac myJavaProgram.java
This will spit out any errors that your source file generates.
- Run it:
Assuming the compilation in step 3 didn't produce any errors, there will be a new
myJavaProgram.class (or whatever you named your java file) in the current directory. Run this
using the java command (without the .class extension though):
java myJavaProgram
- Fix, debug, rinse, lather, and repeat. :-)
Where to get source code for the author's classes:
... by which I mean the Vector, Matrix, and other Java classes we use in the course.
They aren't a part of the standard Java libraries; the author of the textbook wrote them specially for
the book. Grab at the textbook
website and compile away.
How to read lines from a file:
Check out this example.