Question: Java Programming : Sequential Search Algorithm Input: positive integer n array of keys ( integers ) S , indexed from 1 to n a key

Java Programming : Sequential Search Algorithm
Input:
positive integer n
array of keys (integers) S, indexed from 1 to n
a key x
Output: the location of x in S (0 if x is not in S)
Binary Search Algorithm
Input and Output are the same as above, except the input array S must be sorted.
Note: The symbols represent the floor function.
Task 1. Implement Sequential Search Algorithm, test it on 1000; 100,000 and 1,000,000 randomly generated numbers, and record the number of keys that were checked until x was found.
Count for 1,000: _______________
Count for 100,000: _______________
Count for 1,000,000: _______________
Task 2. Implement Binary Search Algorithm, test it on 1000; 100,000 and 1,000,000 randomly generated (sorted) numbers, and record the number of keys that were checked until x was found.
Count for 1,000: _______________
Count for 100,000: _______________
Count for 1,000,000: ____

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 Programming Questions!