Question: Assignment: (1) Using the pseudocode provided above, write two Java functions, gcdRecursive java and gcdlterative.java. (2) Validate the functions by writing a driver program, gedTest.java,
Assignment: (1) Using the pseudocode provided above, write two Java functions, gcdRecursive java and gcdlterative.java. (2) Validate the functions by writing a driver program, gedTest.java, which tests your functions, and verifies that they work correctly. Think about what would be necessary to insure that your program works correctly. (3) Compare the performance of the two functions as follows: Near the top of your driver program, create two variables, recursivesteps and iterativeSteps; initialize each to 0. Insert as the first line of the body of your gedRecursive.java function the statement: recursivesteps = recursivesteps + 1 Insert as the first line of the loop in your gedlterative java function the statement: iterativesteps = iterativesteps + 1 In your driver program, call each function with the same pair of integers, have your drive rativesteps. Repeat this process several times, so that you have more than one data point from which to draw your conclusions. Record the results. r program report the totals for recureivesteps and ite . Deliverables: . Your code: o gcdRecursive.java o gcdlterative.java o gedTest.java Labeled output from a sample run of your gedTest.java program. Discussion: Include the statistics you gathered (in the form of a table listing the comparative number of steps for your two functions) and a discussion of what they mean. Is there any difference between the two functions in terms of number of steps required? Assignment: (1) Using the pseudocode provided above, write two Java functions, gcdRecursive java and gcdlterative.java. (2) Validate the functions by writing a driver program, gedTest.java, which tests your functions, and verifies that they work correctly. Think about what would be necessary to insure that your program works correctly. (3) Compare the performance of the two functions as follows: Near the top of your driver program, create two variables, recursivesteps and iterativeSteps; initialize each to 0. Insert as the first line of the body of your gedRecursive.java function the statement: recursivesteps = recursivesteps + 1 Insert as the first line of the loop in your gedlterative java function the statement: iterativesteps = iterativesteps + 1 In your driver program, call each function with the same pair of integers, have your drive rativesteps. Repeat this process several times, so that you have more than one data point from which to draw your conclusions. Record the results. r program report the totals for recureivesteps and ite . Deliverables: . Your code: o gcdRecursive.java o gcdlterative.java o gedTest.java Labeled output from a sample run of your gedTest.java program. Discussion: Include the statistics you gathered (in the form of a table listing the comparative number of steps for your two functions) and a discussion of what they mean. Is there any difference between the two functions in terms of number of steps required
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
