Programming Exercises Chapter 6: Recursion 14, 15, 16, 17, 20

profileSauraha1996
Project2.pdf

1

Recursion CSCI 3053 01 Dr. Wen Xu Project #2

Project by: Durga Chapagai & Bishant Khadka

2

About Project The project is all about the recursive solution. Recursion in computer science is all about the method where the solution to the problems are depended on the solutions to the smaller instances of the same problems. All of the recursive algorithms have two cases and they are recursive case and base case. Any of that function that calls itself is recursive. Over here, the problems and solutions that we have done for the recursive solution are for,

• The sum of the integers from a to b and a > b. • Outputting an array of characters, c, given the starting and ending indices. • Binary search of an array to locate the value aKey. • The product of two integers a and b. and • A program that outputs the first 45 terms in the Fibonacci sequence by invoking a non-

dynamic recursive method that calculates the nth term of the series. Functions of the source file: Each solution on this project has Main.java and/or Recursion.java file. Recursion java class contain constructor, recursive solution for the question and testing values to output the result. We stated base case and general solution for all the testing values where recursive solution make it easy to function. Some of the sample output of the program are listed below.

3

Output:

14. The sum of the integers from a to b and a > b.

4

15. Outputting an array of characters, c, given the starting and ending indices.

5

16. Binary search of an array to locate the value aKey.

6

17. The product of two integers a and b.

7

20. The outputs of the first 45 terms in the Fibonacci sequence by invoking a non-dynamic recursive method that calculates the nth term of the series.