JavaAlgorithms
Elementary and no so elementary Java algorithms
|
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 > | reverse (ListNode< T > head) |
static< TextendsComparable< T > void | dedup (ListNode< T > head) |
static< TextendsComparable< T > ListNode< T > | kthFromEnd (ListNode< T > head, int k) |
static <TextendsComparable<T> ListNode<T> listAlgorithms.Algorithms.buildList | ( | T[] | vals | ) | [static] |
Build a list from an array of values
vals | an array of values |
Definition at line 35 of file Algorithms.java.
static <TextendsComparable<T> void listAlgorithms.Algorithms.dedup | ( | ListNode< T > | head | ) | [static] |
Remove duplicate elements from a list. The input list is modified.
head |
Definition at line 117 of file Algorithms.java.
static <TextendsComparable<T> ListNode<T> listAlgorithms.Algorithms.kthFromEnd | ( | ListNode< T > | head, |
int | k | ||
) | [static] |
Return the kth element from the end of the list
head | the start of the list |
k | the value of k |
Definition at line 144 of file Algorithms.java.
static <TextendsComparable<T> boolean listAlgorithms.Algorithms.listEquals | ( | ListNode< T > | listA, |
ListNode< T > | listB | ||
) | [static] |
Compare two lists
listA | |
listB |
Definition at line 59 of file Algorithms.java.
static <TextendsComparable<T> ListNode<T> 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
head | the start of a list |
Definition at line 96 of file Algorithms.java.