Download presentation
Presentation is loading. Please wait.
Published byBonnie Norma Cameron Modified over 6 years ago
1
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;
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 ) );
3
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
4
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.
5
Search a directory structure for a file
Loop through the files in this directory If a listing is itself a directory, search that directory
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.