Computers and Technology

Consider the following number guessing game. A target integer chosen from 0 to n (inclusive) is known only to the referee. A player is given k chips and is allowed to ask a series of questions in order to identify the unknown integer as long as there is a chip available. Each question must be presented in the form "Is the target integer less than k?" where k is an integer. The referee will answer the question with either a "Yes" or a "No". The referee will always tell the truth. Each Yes costs the player one chip, while a No costs the player nothing Design a Java program to calculate the minimum number of questions needed to identify any target number for a given n and number of chips k. Your program should take in, as input arguments, values of k and n, and output the value of the minimum number of questions needed in the worst case. The following command finds the minimum number of questions needed for n= 32 and k = 3
java -jar Guess. jar 3 32 0
and returns the following:
Professor Danny
For a target number between 0 and 32, with 3 chips, it takes at most 6 questions to identify the target number in the worst case.
Specific Requirements:
1. Use the dynamic programming technique to design your program.
Explain in English your design and present pseudo code (4pts). Define the optimal substructure (4pts), i. e., recurrence. If your program passes all the test cases, you will receive 8 pts. Additionally, 4pts will be awarded for a bottom up implementation.
2. Make an interactive game where a user is the referee and the program will guess the target integer with the minimum number of questions. (Bonus Points: 4 pts)

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:10, Bearboy5957
Ihave a music player on my phone. i can buy songs, add them to playlists and play them. obviously it would be redundant to store each song in each playlist; each playlist is just a list of pointers to the songs. for this lab you will simulate this behavior. your program will need to have options to: add songs to the system library (you will store the text of the first line of the song, rather than the audio) add playlists add songs to a playlist list playlists play a playlist list all of the songs in the library with a count of how many times each song has been played remove a song from a playlist remove a playlist remove a song from the library (and thus from all playlists that contain it) note that we will not be checking many error cases. in real programming this would be bad, you should usually try to recognize and respond to as many types of errors as you can. in the context of class we are trying to acquaint you with as many concepts as possible, so for the sake of educational efficiency we will not be checking most errors in this lab, you may assume that your user provides correct input. you may add all appropriate error testing if you wish, but we will not be testing for it.
Answers: 2
image
Computers and Technology, 22.06.2019 20:00, Jana1517
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i. e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
image
Computers and Technology, 22.06.2019 21:30, Cheflulu5727
Write a function named printfloatrepresentation(float number) that will print the floating point representation of a number using the format given below. (sign bit) exponent in binary (assumed bit).significandfor example if the number passed an argument is 71 yourprogram should print (0) 10000101 (1).00011100000000000000000similarl y if the number passed to the function as argument is -71 the program should print (1) 10000101 (1).00011100000000000000000
Answers: 3
image
Computers and Technology, 23.06.2019 03:50, dondre54
Q-1 which of the following can exist as cloud-based it resources? a. physical serverb. virtual serverc. software programd. network device
Answers: 1
Do you know the correct answer?
Consider the following number guessing game. A target integer chosen from 0 to n (inclusive) is know...

Questions in other subjects:

Konu
Computers and Technology, 08.12.2021 01:00
Konu
English, 08.12.2021 01:00