Which known the singly linked list linked list
116 Chapter 3. Arrays, Linked Lists, and Reearsion
equality, that is, it tests only whether the corresponding elements in A and B are equal to each other using only a simple notion of equality. This simple equality rule says that two base type variables are equal ifthey have the same value and two object references are equal if they both refer to the same object. Fortunately, if we want to have a deep equality test for arrays of objects, like two-dimensional arrays, the java.utii.Arrays class provides the following method:
deepEquals(A,B): Returns whether A and B are deeply equal. A and B are deeply equal if they have ihe same number of elements and the two elements A[i] and B[i] in each pair of corresponding elements are themselves equal in the simple sense, ·are arrays of the same primitive ty.pe such that Arrays.equals(A[i],B[i]) would.return true, or are arrays of object references such thatA[i] and B[i] are deeply equal.
|
117 | |
---|---|---|
|
head tail
Figure 3.10: Example of a singly linked list whose elements are strings indicating airport codes. The next pointers of each node are shown ·as arrowi. The null object is denoted as 0.