Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey there, i need help with the question below, thank you. Description In this Binary Search Guessing Game, The computer must check for the presence

Hey there, i need help with the question below, thank you.

Description

In this Binary Search Guessing Game, The computer must check for the presence of an integer number in a provided range from start to end (inclusive). At the end of the game, the number is revealed along with the number of tries it took the computer to get the correct number. You should take the number being searched for from user input. The computer should use the binary search algorithm to solve this question.

NOTE:You are provided a range in which the number will be contained.DO NOT CHANGE THE PROVIDEDstartandendVARIABLES.

Input

 n, where n is the number you will search for in the integer array provided. 

Sample Input

 7 

Output

 The number being searched for and the number of tries to find it 

Sample Output

 The number is: 7 It took 4 tries! 

Description

In this Binary Search Guessing Game, The computer must check for the presence of an integer number in a provided range from start to end (inclusive). At the end of the game, the number is revealed along with the number of tries it took the computer to get the correct number. You should take the number being searched for from user input. The computer should use the binary search algorithm to solve this question.

NOTE:You are provided a range in which the number will be contained.DO NOT CHANGE THE PROVIDEDstartandendVARIABLES.

Input

 n, where n is the number you will search for in the integer array provided. 

Sample Input

 7 

Output

 The number being searched for and the number of tries to find it 

Sample Output

 The number is: 7 It took 4 tries! 

the code already provided and that isnt allowed to change is

public class BinarySearchGame

public static void main{String[]args}

int start=1;

int end=10;

}

}

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

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions