Calculate n! Multiply my number by the factorial of the rest of the numbers. if( num > 2 ) return num * factorialR2( num - 1 ); else return 2;
Print a string backwards Print the last character Print the rest of the string backwards System.out.print( str.charAt( str.length() - 1 ) ); if( str.length() > 1 ) reverse( str.substring( 0, str.length() - 1 ) );
Binary Search Calculate mid-point of the range Is the value at mid-point the one you're looking for? If search value < value at mid-point search the low half else search the high half
Towers of Hanoi 1. Move n-1 disks from the source to the spare. 2. Move 1 disk from the source to the destination. 3. Move n-1 disks from the spare to the source.
Search a directory structure for a file Loop through the files in this directory If a listing is itself a directory, search that directory