Goodreads helps you follow your favorite authors. Be the first to learn about new releases!
Start by following Robert Sedgewick.
Showing 1-4 of 4
“If all you have is a hammer, everything seems to be a nail.”
― Algorithms, Part II
― Algorithms, Part II
“Objects are characterized by three essential properties: state, identity, and behavior.”
― Algorithms
― Algorithms
“public class MergeBU
{
private static Comparable[] aux; // auxiliary array for merges
// See page 271 for merge() code.
public static void sort(Comparable[] a)
{ // Do lg N passes of pairwise merges.
int N = a.length;
aux = new Comparable[N];
for (int sz = 1; sz < N; sz = sz+sz) // sz: subarray size
for (int lo = 0; lo < N-sz; lo += sz+sz) // lo: subarray index
merge(a, lo, lo+sz-1, Math.min(lo+sz+sz-1, N-1));
}
}”
― Algorithms
{
private static Comparable[] aux; // auxiliary array for merges
// See page 271 for merge() code.
public static void sort(Comparable[] a)
{ // Do lg N passes of pairwise merges.
int N = a.length;
aux = new Comparable[N];
for (int sz = 1; sz < N; sz = sz+sz) // sz: subarray size
for (int lo = 0; lo < N-sz; lo += sz+sz) // lo: subarray index
merge(a, lo, lo+sz-1, Math.min(lo+sz+sz-1, N-1));
}
}”
― Algorithms
“public class Merge
{
private static Comparable[] aux; // auxiliary array for merges
public static void sort(Comparable[] a)
{
aux = new Comparable[a.length]; // Allocate space just once.
sort(a, 0, a.length - 1);
}
private static void sort(Comparable[] a, int lo, int hi)
{ // Sort a[lo..hi].
if (hi <= lo) return;
int mid = lo + (hi - lo)/2;
sort(a, lo, mid); // Sort left half.
sort(a, mid+1, hi); // Sort right half.
merge(a, lo, mid, hi); // Merge results (code on page 271).
}
}”
― Algorithms
{
private static Comparable[] aux; // auxiliary array for merges
public static void sort(Comparable[] a)
{
aux = new Comparable[a.length]; // Allocate space just once.
sort(a, 0, a.length - 1);
}
private static void sort(Comparable[] a, int lo, int hi)
{ // Sort a[lo..hi].
if (hi <= lo) return;
int mid = lo + (hi - lo)/2;
sort(a, lo, mid); // Sort left half.
sort(a, mid+1, hi); // Sort right half.
merge(a, lo, mid, hi); // Merge results (code on page 271).
}
}”
― Algorithms




