A linked list is a data structure for storing a sequence of element values. Each value is stored in
one node in the linked list. The nodes form a chain: each node contains a reference to the node
containing the next element in the list. For a doubly-linke
Bubble sort is an extremely simple sorting algorithm. We will see later in the course that it is not
an efficient sorting algorithm. However, it is easy to understand and implement.
Here is the pseudo-code of bubble sort:
for (j = a
In the following method, let the problem size N be rowsCols, which is the number of rows and
columns in the square two-dimensional array matrix.
public static boolean isUpperTriangular(double matrix, int rowsCols) cfw_
for (int j = 1; j < rowsCols; j+
Behind the scenes, Java type parameters work by type erasure. The "real" type of a type
parameter is actually Object: the compiler inserts type casts in the program where necessary to
convert Object references to whatever argument type is appropriate.
As a concrete example, let's consider an implementation of the generic ArrayList class. An
ArrayList uses an array of references as its internal storage. The methods of the ArrayList class
use this array to store the elements added to the object. When a c
As we've discussed, a collection is an object whose purpose is to store a collection of references
to other objects. Java provides a number of built-in classes to implement collections; we have
used one,ArrayList<E>, already.
Java defines an interface cal
An iterator is a functor whose purpose is to traverse the elements of a collection.
Conceptually, an interface is a "cursor". At any given time, an iterator may be positioned before
any element in the collection, or may be positioned at the end of the col
Today's computers typically have multi-core CPUs. This means that they are able to execute
multiple streams of instructions simultaneously.
We can take advantage of multiple CPU cores by creating threads. A thread is a stream of
instructions executed with
The remove method takes an integer index, and removes the element at that index from the
ArrayList. Any elements to the right of the index must be moved over one position to the left.
The removed element is returned.
public E r
If the method parameters have the same type parameter as part of their type, the type parameter
serves as a constraint on the types of arguments that may be passed. This (in most cases) will
prevent you from accidentally calling a generic methods using in
Why comment your code?
Explain the intent of the code
Describe the purpose of classes and methods, and how they are meant to be used
Kinds of comments
Java has three kinds of comments.
End-of-line comments: start with /, continue to end of line. Example