Question: I wanna write a java program that searches the target and think about the program efficiently. public class Lab2 { public static void main(String args[])

I wanna write a java program that searches the target and think about the program efficiently.

public class Lab2 { public static void main(String args[]) { Scanner in = new Scanner(System.in); List myList = null; myPopulateRandomly(myList, 10); /* giving the worst-case asymptotic runningtimes, expressed using big- of the respective get(i) operations for either type of List*/ } /*Implement a public static generic mySearch method that takes as its first parameter a List and as its second parameter a target element for which to search.*/ public static int mySearch(ArrayList myList, int target){ /*The idea is that mySearch will return any index of target within the List, and -1 if target does not occur in the List. It may only use the List methods size() and get(i). Youll need to have a nested loop structure. It should check the elements, using the .equals method,*/ } public static void myPopulateRandomly(ArrayList inList,int howMany){ Random a = new Random(); for (int i = 0; i < howMany; i++){ int r = a.nextInt(); inList.add(r); } }

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!