Monday, July 28, 2008

Pseudocode

package recursion;

/**
*
* @author dfreer
*/
public class SmallestNumber {
//How are we going to use recursion to figure out the smallest number???


//take in an array of integers
public static int findSmallest(int [] a)
{
//call another method with a counter
return findSmallestRecursively(a, 0);

//return smallest number (int)
}

public static int findSmallestRecursively(int [] a, int counter)
{
//base case
//if we've reached the end of the array, stop! return minimum!

//if statement to determine whether next number is smaller or larger

//keep track of the smallest number using a variable (int)

//call findSmallestRecursively from itself!! (this is what makes recursion)
//within the recursive call increment counter!
}

public static void main(String []args)
{
//call the first method!
}

No comments: