JavaAlgorithms Elementary and no so elementary Java algorithms
listAlgorithms.Algorithms Class Reference

List of all members.

## Static Public Member Functions

static< TextendsComparable< T >
ListNode< T >
buildList (T[] vals)
static< TextendsComparable< T >
boolean
listEquals (ListNode< T > listA, ListNode< T > listB)
static< TextendsComparable< T >
ListNode< T >
static< TextendsComparable< T >
void
static< TextendsComparable< T >
ListNode< T >
kthFromEnd (ListNode< T > head, int k)

## Detailed Description

Algorithms

A small collection of list algorithms

Jun 19, 2013

Definition at line 23 of file Algorithms.java.

## Member Function Documentation

 static ListNode listAlgorithms.Algorithms.buildList ( T[] vals ) ` [static]`

Build a list from an array of values

Parameters:
 vals an array of values
Returns:
the list construdted from values

Definition at line 35 of file Algorithms.java.

 static void listAlgorithms.Algorithms.dedup ( ListNode< T > head ) ` [static]`

Remove duplicate elements from a list. The input list is modified.

Parameters:

Definition at line 117 of file Algorithms.java.

 static ListNode listAlgorithms.Algorithms.kthFromEnd ( ListNode< T > head, int k ) ` [static]`

Return the kth element from the end of the list

Parameters:
 head the start of the list k the value of k
Returns:
the kth node from the end of the list, or if the list length is less than k, null

Definition at line 144 of file Algorithms.java.

 static boolean listAlgorithms.Algorithms.listEquals ( ListNode< T > listA, ListNode< T > listB ) ` [static]`

Compare two lists

Parameters:
 listA listB
Returns:
true if the lists are equal (and have equal length), false otherwise.

Definition at line 59 of file Algorithms.java.

 static ListNode listAlgorithms.Algorithms.reverse ( ListNode< T > head ) ` [static]`

Reverse the element in a list

```                               A -> B -> C -> D
A -> null                 B -> C -> D -> null
B -> A -> null            C -> D -> null
C -> B -> A -> null       D -> null
D -> C-> B -> A -> null
```

The input list is reversed, so its original structure is destroyed

Parameters:
 head the start of a list
Returns:
the head of the reversed list

Definition at line 96 of file Algorithms.java.

The documentation for this class was generated from the following file: