Question: USING JAVA: Your program should implement ALGORITHM 3, The Binary Search Algorithm, described in the sub-section Searching Algorithms, in section 3.1, Algorithms. Your program should
USING JAVA: Your program should implement ALGORITHM 3, The Binary Search Algorithm, described in the sub-section "Searching Algorithms", in section 3.1, "Algorithms".
Your program should prompt the user to enter 10 integers in ascending order. Then your program should prompt the user to enter the number they want to search. Then your program should perform a binary search and print the subscript of the integer if found, and print 0 if not found. Make your program adhere to ALGORITHM 3. Leave a[0] unused. Store the data in a[1] to a[n]. If the value is not found, return location 0.
ALGORITHM 3 The Binary Search Algorithm. procedure binary search (x : integer, aj, a2, ..., an: increasing integers) i :=1{i is left endpoint of search interval} j:=n {j is right endpoint of search interval while i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
