Computer Science Fundamentals (CS153 2003S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Back to When Things Go Wrong. On to Exam 2.
Held: Friday, 4 April 2003
Summary: Today we visit one of Java's core data structures: the array. We consider two applications of arrays in writing algorithms.
Related Pages:
Notes:
Overview:
Rational classes allowed
you to group logical aspects of a rational number into a whole.
type[] name = new type[size];
stuff,
you would write
double[] stuff = new double[5];
type[] name = { val1, val2, ..., valn }
;
int[] stuff = {3, 2, 6, 5};
name[index]
stuff with
stuff[3]
i held the value 3, then we could get
element 3 of the stuff with
stuff[i]
name.length
public double sum(double[] stuff) {
double total = 0; // The total of the numbers in stuff
int i; // A counter variable for stepping through
// the array
// Step through the array, adding each subsequent value
for(i = 0; i < stuff.length; i = i + 1) {
total = total + stuff[i];
}
// Return the total value
return total;
} // sum
public static long fib(int n) {
if (n < 2)
return n;
else
return fib(n-1) + fib(n-2);
} // fib(int)
Back to When Things Go Wrong. On to Exam 2.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue May 6 09:20:54 2003.
The source to the document was last modified on Thu Jan 16 15:16:14 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2003S/Outlines/outline.36.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby