[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Project] [Outlines] [Labs] [Assignments] [Quizzes] [Exams] [Examples] [EIJ] [JPDS] [Tutorial] [API]
Back to Analyzing Recursive Algorithms. On to Project Discussion: Specifications.
Held Wednesday, March 1, 2000
Overview
Today we visit one of Java's core data structures: the array. We consider two applications of arrays in writing algorithms.
Notes
Contents
Summary
StudentInfo classes allowed
you to group logical aspects of a student in one 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
Tuesday, 18 January 2000
Wednesday, 1 March 2000
Back to Analyzing Recursive Algorithms. On to Project Discussion: Specifications.
[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Project] [Outlines] [Labs] [Assignments] [Quizzes] [Exams] [Examples] [EIJ] [JPDS] [Tutorial] [API]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/2000S/Outlines/outline.23.html
Source text last modified Wed Mar 1 09:51:45 2000.
This page generated on Wed Mar 1 09:54:29 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu