Question: Please write the code for such a function, I have included my binomial search. Also C programming if you would kindly You need to submit

Please write the code for such a function, I have included my binomial search. Also C programming if you would kindly

You need to submit the second code with Guessing Game based on Ternary Search.

Ternary Search presupposes that during the game the search space is reduced by 2/3 rather than cut by half. For example, let us suppose that low=0 and high is 90. We define two markers whose values would be

m1=30

m2=60

We will ask to press a certain key if

target number is equal to m1 or m2

target number is greater than m2

target number smaller than m2

New search space would contain only 30 numbers. Continue accordingly.

here is the first part of the trinomial aka break 2 added inputs into 3

#include "pch.h"

#include

int main()

{

int high, low, middle;

char input;

printf("Please enter low bound ");

scanf_s("%d", &low);

printf("Please enter high bound ");

scanf_s("%d", &high);

printf("Your number has to be between %d and %d ", low, high);

while (low <= high)

{

middle = ?;

printf(" Please, press E or e if your number is equal to %d ", middle);

printf(" Please, press G or g if your number is greater than %d ", middle);

printf(" Please, press S or s if your number is smaller than %d ", middle);

scanf_s(" %c", &input);

if (input == 'E' || input == 'e')

{

printf("Done! I've guessed your number ");

low = ?; // MAKE LOOP CONDITION FALSE

}

else

{

if (input == 'G' || input == 'g')

low = ?;

else

high = ?;

}

}

printf(" Thanks for playing! ");

}

here's what I have for a binomial function for a guessing game in the C language.

#include

int main() { int min; int max; int middle; char input;

printf("Please enter a minimum number: ");

scanf("%d", &min);

printf("Please enter a maximum number: ");

scanf("%d", &max);

printf("You minimum values is %d, and you maximum value is %d : ", min, max); /* * find how many questions you need to ask * print: the program is going to guess your number */

while (min<=max) { middle = (min + max) / 2;

printf("Please enter E if the number is equal to %d ", middle); printf("Please enter L if the number is larger to %d ", middle); printf("Please enter S if the number is smaller to %d ", middle);

scanf("%c", &input);

if (input == 'E') { printf("The program has guessed your number "); /*let's break out of this!*/ min = max + 1; } else { if (input == 'L') min = middle + 1;

else max = middle - 1; } if (input != 'E') { printf("OK this program has ran every single number you picked... you are a dirty cheater. ")

} } }

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