Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a Java test drive following this step: (1) declare and initialize an int N to 10 (change to 1000000 later) declare and new an

image text in transcribed
Implement a Java test drive following this step: (1) declare and initialize an int N to 10 (change to 1000000 later) declare and new an array of n strings, say, x, which simulates Facebook's user names (2) initialize each string element by using x[i] String.valueof(((int) (Math.random()*100000000))); (just use some random digits to pretend to be username) (3) set a target="345461223" (later on change to x[N/2]) (4) write a loop to perform linear search for the target in x (5) surround the loop using long t0 = System.currentTimeMillis(); //loop long ti = System.currentTimeMillis(); (6) write codes to print out the index position where the target is located at or -1 if target is not present. Print out ti-to as well, which is the time spent on the search (7) modify the your codes of creating x[i] so that x[i] will be sorted increasingly. (8) Run the linear search again. (9) get the BinarySearch.java from BB, modify it to deal with string array. (change "w" to ".equals()", xay to m.compareTo(Y)

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_2

Step: 3

blur-text-image_3

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

=+ Are there additional forms of employee representation?

Answered: 1 week ago

Question

=+What is the nature of their impact?

Answered: 1 week ago

Question

=+Is it possible to operate union-free?

Answered: 1 week ago