home—info—lects—labs—exams—hws
D2L—tutor/PIs—zoom (snow day)
Object120 + its docs—java.lang docs—java.util docs
array practice
multiple passes; mutation
For the code Insult.java,
-
Draw a picture (memory-diagram) of what happens, as main is called.
-
Design-issues:
increasing randomness (what happened with java Insults | sort?);
introduce the idea of a String's hashCode.
-
Introduce, and write unit tests for, PartitionBefore.java
(taking time to think of good unit-tests: PartitionWTests.java).
We'll write three different versions/variants of partition, and consider issues:
-
partition, a version using two passes (first copy over the small values, then make a second pass to copy over the large values)
-
Discuss: memory-diagram, of the array-references being passed.
When two variables each hold a reference to the same underlying object,
it's called “aliasing”.
-
partitionRR, a version using one pass (but, it reverses the right side)
-
Discuss (using diagrams):
why do these programs act differently?
AliasingVsNot.java
-
partitionRRMutate, as partitionRR but as a void function it
modifies the array it's given.
home—info—lects—labs—exams—hws
D2L—tutor/PIs—zoom (snow day)
Object120 + its docs—java.lang docs—java.util docs
 This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarland radford.edu |
 |