Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java and do the table plz - Question 1: You have to program an application that search for a certain number in an array

image text in transcribed

in java and do the table plz

- Question 1: You have to program an application that search for a certain number in an array with size N and it should display a message if that number is available or not and prints its index if it's there. If not then display a proper message on the screen telling the user that this element is not there. - Your task(s): i. Create an array of a large size (starting with 400,000 elements) and store random numbers into it (the random numbers range should be from 1 to N using the rand function. Alternatively, y ii. Using sequential search: a. Ask the user to search for a certain number that exists in the array and display the time that your computer took to find this element in the array. b. Ask the user to search for another number that doesn't exist in the array (a negative value or a number that is greater than N ) and display the time that your computer took to finish the searching process. c. Repeat the same steps (step a and b) with a larger value for N at least 8 times (start with 400K,800K,1600K,3200K,6400K,12800K, till 25600K ). iii. Repeat the same steps but using the binary search method (Hint: Rearrange the array's elements as needed to take advantage of the binary search). 1 iv. Evaluate the implemented solutions by creating a time table that shows the difference between the two algorithms and the difference if the element exists or not in the array. Noterif your program keeps showing the time of the search as 0 's, try to delay your algorithm for a fraction of a second using: TimeUnit.MILLISECONDS.sleep(1); After or before the IF statement searching for the element, but inside the loop. - What to submit: 1) A time table that shows the difference between the two algorithms and the difference if the element exists or not in the array (template below). 2) A well-organized Java program with proper output messages and understandable comments on the code. 3) Screenshots of the test cases: After you derive multiple input test cases to verify your program is working, submit screenshots of the output screen. - Template

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

Probability & Statistics For Engineers & Scientists

Authors: Ronald E. Walpole, Raymond H. Myers, Sharon L. Myers, Keying

7th Edition

9789813131279, 130415294, 9813131276, 978-0130415295

Students also viewed these Databases questions