Java Lab 8: Recursion


Due Date: Monday December 10 th at 11:59 pm

Assignment: The purpose of this assignment is to write a list of recursive functions and learn how to use them. This project does not try to solve any specific problem but will merely serve as an assignment that will allow us to learn recursion. The methods that you are expected to write and test are:
// FACTORIAL
 public static int factorial(int n){
   return 0;
 }
 // EXPONENT
 public static double power(double x, int n){
   return 0;
 } 
 // TOWER OF HANOI
 public static void Hanoi(int n, char source, char dest, char inter ){
   
 } 
 // FIND THE Greatest Common Divisor (GCD) using recursion
    public static int GCD(int n, int m){
   return 0;
 } 
 // PRINT a STRING BACKWARDS USING RECURSION
 public static void reversePrint(String name){
   
 } 
 // Suppose that the defintion of the function foo is
 // foo(n) = 1  is  n>=0 
 //        = foo(n-1) if  3<= n <= 10
 //        = foo(n-1) + foo(n-2)  if n > 10
 // write a recursive function to compute foo for any n
 public static int foo(int n){
   return 0;
 }
 // LINEAR SEARCH IN AN ARRAY
 public static int linearSearch(int target, int[] A, int pos){
   return 0;
 }
 // RECURSIVE BINARY SEARCH
 public static int binarySearch(int target, int[] A, int start, int end){
   return 0;
 }

Checking your results

Run the program with driver provided. 

Getting Started 

Download the lab8.zip file. Save the zip file to your C:\Temp directory and unzip the files. Open the directory Temperatures. You should see the following files:
  • project.mcp (the project file for this Java application)
  • driver.java (a source file for this Java application)
    • This is the driver class
    • This class creates the necessary objects, and initiates the appropriate member functions to solve the problem
    • You will also be responsible for completing this file, so that the output models the executable

Handing in your Solution

Your solutions should be in the form of .zip files. When we grade your solution we will unzip the folder and execute the project. If your project does not run you will lose the execution points for that lab.

Your Solution zip file must contain all the files in your projects

Your teaching assistants will show you how to zip up the files for submission. Instructions are also in the Tutorial document that is available
 

Click on this link to Submit your zip file