
*************Question below: ------------------------
Code in Java. Code must be recursive.
*DriverMain.java:
import java.util.*;
import java.lang.*;
import java.io.*;
//
public class DriverMain {
public static void main (String[] args) {
Scanner s = new Scanner(System.in);
int N = s.nextInt();
int A[] = new int[N];
for (int i = 0; i < N; i++) {
A[i] = s.nextInt();
}
ProblemSolution problemSolution = new ProblemSolution();
System.out.print(problemSolution.findMagicIndex(A, N));
}
}
*ProblemSolution.java:
import java.util.*;
import java.lang.*;
import java.io.*;
class ProblemSolution {
public static int findMagicIndex(int[] a, int n) {
//CODE GOES HERE
}
}
*entrypoint.cz:
DriverMain.java
![Magic index in an array a[1.n] is defined to be an index such
that a[ i] = i. Given an array of integers, write
a recursive method to find the first magic index from left to
right. If one exists in the given array, return the index
number i, otherwise return -1.
Here are some test cases. The first number is the size of the
array.
Inputl
6
-2 -2 3 -2 -2 -1
Outputl
-1
Input2
-17234
Output2
2](https://content.bartleby.com/qna-images/question/b7b9d31a-c86f-4d0e-8309-e29e98c37251/2805c610-fca9-4f6f-af86-994c8dbfef95/e609ru_thumbnail.jpeg)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- using java *two classes*arrow_forward1)Create a complete Java class that can be used to create a Computer object as described below:A Computer has a:- Manufacturer- Disk Size- Manufacturing Date- Number of coresa) Add all instance variables (data encapsulation is expected).b) The class must have getters and setters for all instance variables.c) The class must have two constructors: a no-arg constructor and a constructor thatreceives input parameters for each instance variable.d) Implement a toString() method for your class. 2)Write a Java program TestComputer, which creates three Computer objects with the informationbelow:a) - Manufacturer: Dell- Disk Size: 1189160321024 bytes- Manufacturing Date: April 1, 2020- Number of cores: 2b) - Manufacturer: Apple Inc- Disk Size: 269283712040 bytes- Manufacturing Date: March 31, 2020- Number of cores: 4c) Create your own Object. You can mimic your actual personal computer or use a no-argsconstructor.Print the three objects using toString() method to show all data fieldsarrow_forwardInstructions-Java Assignment is to define a class named Address. The Address class will have three private instance variables: an int named street_number a String named street_name and a String named state. Write three constructors for the Address class: an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice, a constructor that takes the street values as input but defaults the state to "Arizona", and a constructor that takes all three pieces of information as input Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses. Run your code to make sure it works. Next add the following public methods to the Address class and test them from main as you go: Write getters and…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





