Question: In Java: 3. The following recursive function g (defined with pseudocode) is initially invoked with an i value of 1. L is a list (array)

In Java:

In Java: 3. The following recursive function g (defined with pseudocode) isinitially invoked with an i value of 1. L is a list

3. The following recursive function g (defined with pseudocode) is initially invoked with an i value of 1. L is a list (array) of MAX integers. [In this pseudocode, L has an initial index of 1 and a final index of MAX. Your code can adjust the indices of L as appropriate for your programming language.] You will need the value of MAX in the function/method g so make sure you can get that value in the function/method either as an additional parameter or by finding the size of L g(list L; positive integer i; integer x) print "Function g is called with i- "i+" and user input xand MAX -"+MAX if i > MAX then MAX print "i is greater than MAX" print *"Returning-1" return -1 else if L [i] = x then "is x"+ x print "The value of L["+i+"] " (L[i]'s value) print"**Returning MAX"+MAX return MAX print" x "+x+ "is not equal to L["++"]"+Li] return g(L, i + 1, x) end if end if end function g 3.a. In a new program, implement this function/method g 10 pts 3.b. Write a main method/program that will allow the user to enter values for x and then call the function/method g. In the main method, the list L should be declared as something like an array with size of MAX. The list L should be initialized with random values between 0 and 10 *MAX. Print out the values of L in a table of no more than 10 columns across. E.g. for a list of 50 values you could print 5 rows of 10 columns or 10 rows of 5 columns but not 2 rows of 25 columns The main method/program should then get input from the user forx. The user will have two choices for giving x a value. 1) The user can choose to enter a value for x where the main method/program tells the user the valid input range and error checks the input given by the user

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!