Algorithms and Data Structures in
an Object-Oriented Framework (“ADSOOF”)
Code for “Using Arrays” section
- UseArrays1.java
Demonstration of a static method which tests whether an integer is in
an array of integers.
- UseArrays2.java
Demonstration of a static method which tests whether a string is in
an array of strings.
- UseArrays3.java
Demonstration of a static method which returns the position of an integer
in an array of integers (checking lowest indexed cells first).
- UseArrays4.java
Demonstration of a static method which returns the position of an integer
in an array of integers (checking highest indexed cells first).
- UseArrays5.java
Demonstration of a static method which returns the position of a string
in an array of strings (checking lowest indexed cells first).
- UseArrays6.java
Demonstrates a static method which destructively changes all occurrences of one
integer to another in an array of integers.
- UseArrays7.java
Demonstrates a static method which constructively changes all occurrences of one
integer to another in an array of integers.
- UseArrays8.java
Demonstrates a static method which adds an integer to the end of an array of
integers (can only be done constructively).
- UseArrays9.java
Demonstrates a static method which removes the integer at the end of an array of
integers (can only be done constructively).
- UseArrays10.java
Demonstrates a static method which removes an integer given as an argument
from an array of integers (can only be done constructively). Lowest
indexed occurrence removed.
- UseArrays11.java
Demonstrates a static method which removes an integer given as an argument
from an array of integers (can only be done constructively). All occurrences
removed.
- UseArrays12.java
Demonstrates a static method which removes an integer whose position is given
given as an argument from an array of integers (can only be done constructively).
- UseArrays13.java
Like
UseArrays6.java
, but uses Java's clone
method
to copy the array, rather than a copy
method we have
written ourselves.
- UseArrays14.java
Demonstrates a static method for returning the largest integer in an array
of integers.
- UseArrays15.java
Demonstrates a static method for returning the position of the largest integer
in an array of integers.
- UseArrays16.java
Demonstrates a static method for returning the longest string
in an array of strings.
Extra code, demonstrating recursive techniques
- UseArrays17.java
Like
UseArrays14.java
, but uses tail recursion instead of iteration.
- UseArrays18.java
Demonstrates a static method for returning the largest integer in an array
of integers. Uses single recursion which is not tail recursion.
- UseArrays19.java
Demonstrates a static method for returning the largest integer in an array
of integers. Uses binary recursion.
- UseArrays20.java
Demonstrates a static method for returning the largest integer in an array
of integers. Uses binary recursion, and also shows Java's conditional operator.
- UseArrays21.java
Demonstrates a static method for returning the largest integer in an array
of integers. Use binary recursion badly because there are repeated calls
instead of saved results.
- UseArrays22.java
Like
UseArrays21.java
, but replaces all use of if
by the
conditional operator.
- UseArrays23.java
Like
UseArrays19.java
, but gives a count of the number of comparisons made.
- UseArrays24.java
Like
UseArrays21.java
, but gives a count of the number of comparisons made.
- UseArrays25.java
Demonstrates a very inefficient recursive method to do the same as
UseArrays10.java
: remove the first occurrence of an integer given as an argument.
- UseArrays26.java
An efficient recursive method to do remove the first occurrence of an integer given as an argument.
- UseArrays27.java
Like
UseArrays26.java
, but everything done with recursion.
Matthew Huntbach
Last modified: 16 July 2019