Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions