How can i make it clearly Guessing game?How do I efficiently iterate over each entry in a Java Map?How can I concatenate two arrays in Java?Fastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How can I create an executable JAR with dependencies using Maven?How do I determine whether an array contains a particular value in Java?How can I convert a stack trace to a string?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?
How do we know the LHC results are robust?
Two monoidal structures and copowering
Integer addition + constant, is it a group?
Detecting if an element is found inside a container
Applicability of Single Responsibility Principle
What Brexit proposals are on the table in the indicative votes on the 27th of March 2019?
What is the best translation for "slot" in the context of multiplayer video games?
Do the temporary hit points from Reckless Abandon stack if I make multiple attacks on my turn?
How long to clear the 'suck zone' of a turbofan after start is initiated?
Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?
Do sorcerers' subtle spells require a skill check to be unseen?
Term for the "extreme-extension" version of a straw man fallacy?
Risk of infection at the gym?
Are student evaluations of teaching assistants read by others in the faculty?
How to run a prison with the smallest amount of guards?
How do scammers retract money, while you can’t?
Why escape if the_content isnt?
What happens if you roll doubles 3 times then land on "Go to jail?"
What is the difference between "behavior" and "behaviour"?
Is `x >> pure y` equivalent to `liftM (const y) x`
How does buying out courses with grant money work?
Crossing the line between justified force and brutality
How can i make it clearly Guessing game?
How do I efficiently iterate over each entry in a Java Map?How can I concatenate two arrays in Java?Fastest way to determine if an integer's square root is an integerHow do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How can I create an executable JAR with dependencies using Maven?How do I determine whether an array contains a particular value in Java?How can I convert a stack trace to a string?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?
how can i do that someone ?
i had problem about that
Enter the mode: A
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
I have generated a random integer between 1 and 10.
Try to guess: 5
No. It is smaller!
Try to guess: 3
Done.
Enter the mode: B
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
Generate a random integer between 1 and 10...
Which method I should use to guess it?
1: Binary search
2: Interpolation search
Enter your choice of the method: 1
Is it 5? (<, >, =)
<
Is it 3?
Done.
java
|
show 1 more comment
how can i do that someone ?
i had problem about that
Enter the mode: A
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
I have generated a random integer between 1 and 10.
Try to guess: 5
No. It is smaller!
Try to guess: 3
Done.
Enter the mode: B
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
Generate a random integer between 1 and 10...
Which method I should use to guess it?
1: Binary search
2: Interpolation search
Enter your choice of the method: 1
Is it 5? (<, >, =)
<
Is it 3?
Done.
java
5
What's the problem?
– BretC
Mar 7 at 12:56
i dont understand second one i did first but second how can i do that ?
– Nikolas Folgan
Mar 7 at 12:59
Show us your coding attempt with specific questions and we can help...
– Idle_Mind
Mar 7 at 13:32
i just new started to learn.. just i did first part but here i dont know what should i do ; 1 Enter the maximal possible integer: 10 Generate a random integer between 1 and 10... Which method I should use to guess it? 1: Binary search 2: Interpolation search Enter your choice of the method: 1 Is it 5? (<, >, =) < Is it 3? Done.
– Nikolas Folgan
Mar 7 at 13:34
So Mode A is where the PROGRAM selects a number in the specified range and YOU need to guess it. Mode B is where YOU select a number in the specified range and the PROGRAM needs to guess it with the SEARCH PATTERN selected. This is an assignment where you can easily GOOGLE all the parts.
– George Derpi
Mar 7 at 13:38
|
show 1 more comment
how can i do that someone ?
i had problem about that
Enter the mode: A
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
I have generated a random integer between 1 and 10.
Try to guess: 5
No. It is smaller!
Try to guess: 3
Done.
Enter the mode: B
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
Generate a random integer between 1 and 10...
Which method I should use to guess it?
1: Binary search
2: Interpolation search
Enter your choice of the method: 1
Is it 5? (<, >, =)
<
Is it 3?
Done.
java
how can i do that someone ?
i had problem about that
Enter the mode: A
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
I have generated a random integer between 1 and 10.
Try to guess: 5
No. It is smaller!
Try to guess: 3
Done.
Enter the mode: B
Enter the minimal possible integer: 1
Enter the maximal possible integer: 10
Generate a random integer between 1 and 10...
Which method I should use to guess it?
1: Binary search
2: Interpolation search
Enter your choice of the method: 1
Is it 5? (<, >, =)
<
Is it 3?
Done.
java
java
edited Mar 7 at 13:04
Nikolas Folgan
asked Mar 7 at 12:53
Nikolas FolganNikolas Folgan
34
34
5
What's the problem?
– BretC
Mar 7 at 12:56
i dont understand second one i did first but second how can i do that ?
– Nikolas Folgan
Mar 7 at 12:59
Show us your coding attempt with specific questions and we can help...
– Idle_Mind
Mar 7 at 13:32
i just new started to learn.. just i did first part but here i dont know what should i do ; 1 Enter the maximal possible integer: 10 Generate a random integer between 1 and 10... Which method I should use to guess it? 1: Binary search 2: Interpolation search Enter your choice of the method: 1 Is it 5? (<, >, =) < Is it 3? Done.
– Nikolas Folgan
Mar 7 at 13:34
So Mode A is where the PROGRAM selects a number in the specified range and YOU need to guess it. Mode B is where YOU select a number in the specified range and the PROGRAM needs to guess it with the SEARCH PATTERN selected. This is an assignment where you can easily GOOGLE all the parts.
– George Derpi
Mar 7 at 13:38
|
show 1 more comment
5
What's the problem?
– BretC
Mar 7 at 12:56
i dont understand second one i did first but second how can i do that ?
– Nikolas Folgan
Mar 7 at 12:59
Show us your coding attempt with specific questions and we can help...
– Idle_Mind
Mar 7 at 13:32
i just new started to learn.. just i did first part but here i dont know what should i do ; 1 Enter the maximal possible integer: 10 Generate a random integer between 1 and 10... Which method I should use to guess it? 1: Binary search 2: Interpolation search Enter your choice of the method: 1 Is it 5? (<, >, =) < Is it 3? Done.
– Nikolas Folgan
Mar 7 at 13:34
So Mode A is where the PROGRAM selects a number in the specified range and YOU need to guess it. Mode B is where YOU select a number in the specified range and the PROGRAM needs to guess it with the SEARCH PATTERN selected. This is an assignment where you can easily GOOGLE all the parts.
– George Derpi
Mar 7 at 13:38
5
5
What's the problem?
– BretC
Mar 7 at 12:56
What's the problem?
– BretC
Mar 7 at 12:56
i dont understand second one i did first but second how can i do that ?
– Nikolas Folgan
Mar 7 at 12:59
i dont understand second one i did first but second how can i do that ?
– Nikolas Folgan
Mar 7 at 12:59
Show us your coding attempt with specific questions and we can help...
– Idle_Mind
Mar 7 at 13:32
Show us your coding attempt with specific questions and we can help...
– Idle_Mind
Mar 7 at 13:32
i just new started to learn.. just i did first part but here i dont know what should i do ; 1 Enter the maximal possible integer: 10 Generate a random integer between 1 and 10... Which method I should use to guess it? 1: Binary search 2: Interpolation search Enter your choice of the method: 1 Is it 5? (<, >, =) < Is it 3? Done.
– Nikolas Folgan
Mar 7 at 13:34
i just new started to learn.. just i did first part but here i dont know what should i do ; 1 Enter the maximal possible integer: 10 Generate a random integer between 1 and 10... Which method I should use to guess it? 1: Binary search 2: Interpolation search Enter your choice of the method: 1 Is it 5? (<, >, =) < Is it 3? Done.
– Nikolas Folgan
Mar 7 at 13:34
So Mode A is where the PROGRAM selects a number in the specified range and YOU need to guess it. Mode B is where YOU select a number in the specified range and the PROGRAM needs to guess it with the SEARCH PATTERN selected. This is an assignment where you can easily GOOGLE all the parts.
– George Derpi
Mar 7 at 13:38
So Mode A is where the PROGRAM selects a number in the specified range and YOU need to guess it. Mode B is where YOU select a number in the specified range and the PROGRAM needs to guess it with the SEARCH PATTERN selected. This is an assignment where you can easily GOOGLE all the parts.
– George Derpi
Mar 7 at 13:38
|
show 1 more comment
1 Answer
1
active
oldest
votes
Learning different search algorithms is very interesting.
Since you say that you need to learn, I present you the theoretical explanation of both algorithms.
Binary search
This is a computer science search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.
Interpolation search
Instead of calculating the midpoint, interpolation search estimates the position of the target value, taking into account the lowest and highest elements in the array as well as length of the array. This is only possible if the array elements are numbers. It works on the basis that the midpoint is not the best guess in many cases. For example, if the target value is close to the highest element in the array, it is likely to be located near the end of the array.
To find the position to be searched, it uses following formula.
pos = lo + [ (x-arr[lo])*(hi-lo) / (arr[hi]-arr[Lo]) ]
arr[] -> Array where elements need to be searched
x -> Element to be searched
lo -> Starting index in arr[]
hi -> Ending index in arr[]
Source Wikipedia Binary Search
How you wish to implement them is at your own discretion.
If you are stuck with that and post the code of your attempt, we can help you more.
Thank You George !
– Nikolas Folgan
Mar 7 at 17:09
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044281%2fhow-can-i-make-it-clearly-guessing-game%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Learning different search algorithms is very interesting.
Since you say that you need to learn, I present you the theoretical explanation of both algorithms.
Binary search
This is a computer science search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.
Interpolation search
Instead of calculating the midpoint, interpolation search estimates the position of the target value, taking into account the lowest and highest elements in the array as well as length of the array. This is only possible if the array elements are numbers. It works on the basis that the midpoint is not the best guess in many cases. For example, if the target value is close to the highest element in the array, it is likely to be located near the end of the array.
To find the position to be searched, it uses following formula.
pos = lo + [ (x-arr[lo])*(hi-lo) / (arr[hi]-arr[Lo]) ]
arr[] -> Array where elements need to be searched
x -> Element to be searched
lo -> Starting index in arr[]
hi -> Ending index in arr[]
Source Wikipedia Binary Search
How you wish to implement them is at your own discretion.
If you are stuck with that and post the code of your attempt, we can help you more.
Thank You George !
– Nikolas Folgan
Mar 7 at 17:09
add a comment |
Learning different search algorithms is very interesting.
Since you say that you need to learn, I present you the theoretical explanation of both algorithms.
Binary search
This is a computer science search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.
Interpolation search
Instead of calculating the midpoint, interpolation search estimates the position of the target value, taking into account the lowest and highest elements in the array as well as length of the array. This is only possible if the array elements are numbers. It works on the basis that the midpoint is not the best guess in many cases. For example, if the target value is close to the highest element in the array, it is likely to be located near the end of the array.
To find the position to be searched, it uses following formula.
pos = lo + [ (x-arr[lo])*(hi-lo) / (arr[hi]-arr[Lo]) ]
arr[] -> Array where elements need to be searched
x -> Element to be searched
lo -> Starting index in arr[]
hi -> Ending index in arr[]
Source Wikipedia Binary Search
How you wish to implement them is at your own discretion.
If you are stuck with that and post the code of your attempt, we can help you more.
Thank You George !
– Nikolas Folgan
Mar 7 at 17:09
add a comment |
Learning different search algorithms is very interesting.
Since you say that you need to learn, I present you the theoretical explanation of both algorithms.
Binary search
This is a computer science search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.
Interpolation search
Instead of calculating the midpoint, interpolation search estimates the position of the target value, taking into account the lowest and highest elements in the array as well as length of the array. This is only possible if the array elements are numbers. It works on the basis that the midpoint is not the best guess in many cases. For example, if the target value is close to the highest element in the array, it is likely to be located near the end of the array.
To find the position to be searched, it uses following formula.
pos = lo + [ (x-arr[lo])*(hi-lo) / (arr[hi]-arr[Lo]) ]
arr[] -> Array where elements need to be searched
x -> Element to be searched
lo -> Starting index in arr[]
hi -> Ending index in arr[]
Source Wikipedia Binary Search
How you wish to implement them is at your own discretion.
If you are stuck with that and post the code of your attempt, we can help you more.
Learning different search algorithms is very interesting.
Since you say that you need to learn, I present you the theoretical explanation of both algorithms.
Binary search
This is a computer science search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.
Interpolation search
Instead of calculating the midpoint, interpolation search estimates the position of the target value, taking into account the lowest and highest elements in the array as well as length of the array. This is only possible if the array elements are numbers. It works on the basis that the midpoint is not the best guess in many cases. For example, if the target value is close to the highest element in the array, it is likely to be located near the end of the array.
To find the position to be searched, it uses following formula.
pos = lo + [ (x-arr[lo])*(hi-lo) / (arr[hi]-arr[Lo]) ]
arr[] -> Array where elements need to be searched
x -> Element to be searched
lo -> Starting index in arr[]
hi -> Ending index in arr[]
Source Wikipedia Binary Search
How you wish to implement them is at your own discretion.
If you are stuck with that and post the code of your attempt, we can help you more.
answered Mar 7 at 14:23
George DerpiGeorge Derpi
440110
440110
Thank You George !
– Nikolas Folgan
Mar 7 at 17:09
add a comment |
Thank You George !
– Nikolas Folgan
Mar 7 at 17:09
Thank You George !
– Nikolas Folgan
Mar 7 at 17:09
Thank You George !
– Nikolas Folgan
Mar 7 at 17:09
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044281%2fhow-can-i-make-it-clearly-guessing-game%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
What's the problem?
– BretC
Mar 7 at 12:56
i dont understand second one i did first but second how can i do that ?
– Nikolas Folgan
Mar 7 at 12:59
Show us your coding attempt with specific questions and we can help...
– Idle_Mind
Mar 7 at 13:32
i just new started to learn.. just i did first part but here i dont know what should i do ; 1 Enter the maximal possible integer: 10 Generate a random integer between 1 and 10... Which method I should use to guess it? 1: Binary search 2: Interpolation search Enter your choice of the method: 1 Is it 5? (<, >, =) < Is it 3? Done.
– Nikolas Folgan
Mar 7 at 13:34
So Mode A is where the PROGRAM selects a number in the specified range and YOU need to guess it. Mode B is where YOU select a number in the specified range and the PROGRAM needs to guess it with the SEARCH PATTERN selected. This is an assignment where you can easily GOOGLE all the parts.
– George Derpi
Mar 7 at 13:38