Basic sorting algorithms, hashing via hashCode/equals, and recursion patterns.
Bubble sort swaps adjacent out-of-order pairs; selection sort takes the smallest remaining each pass; insertion sort inserts each value into a sorted prefix. Collections.sort orders a List via Comparable. Hashing maps keys to indices via hashCode(); equal objects must share a hash, so override hashCode() with equals(). Recursion: a method calling itself; a base case stops it. Examples: factorial, Fibonacci, binary search.
Example
int fact(int n) {
return(n <= 1) ? 1 : n * fact(n - 1);
}
No comments yet.