1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
uranmaximum [27]
2 years ago
10

Suppose that an array of strings contains ["blueberry", "chocolate", "coconut", "coffee", "mint", "strawberry", "vanilla"]. How

many compares are used for a successful search for "mint" with binary search?
Computers and Technology
1 answer:
Mademuasel [1]2 years ago
4 0

Answer:

The answer is "4".

Explanation:

In the given question the answer is "4" because the array of indexing always starts from the "0" position and the "mint" element value store in the fourth position.

This position can also be defined by the program code, which is defined in the below section. please find the code as well as its output.

program:

#include<iostream> //defining header file

using namespace std;  

int BS(string Arr[], string val,int n) //defining method BS

{  

int length=0 ;//defining integer variable length  

int range = n-1; //defining range variable that takes one less value from n

while (length <= range)//defining while loop to check the length is less then equal to the range

{  

int max=length+(range-length)/2;//defining max to store value  

int rest; //defining integer variable rest  

if (val == (Arr[max])) //defining if block that check val equal to Arr

{

rest= 0; //use rest variable to assign value 0

}

if (rest==0)//defining if block that check rest equal to 0

{

return max;   //return max value

}

if (val > (Arr[max])) //defining if block that check val greater then Arr value

{

length=max+1; //use length variable that hold max+1 value  

}

else //defining else block

{

range= max-1; //use range variable that hold max-1 value  

}

}  

return -1; //return value -1

}  

int main()//defining main method  

{  

string Arr[]={"blueberry","chocolate","coconut","coffee","mint","strawberry","vanilla"};  

string val = "mint"; //defining string variable val that store "mint" value

int n=7;//defining integer variable n that store array element value  

cout<<BS(Arr,val,n); //use print method to call method "BS" and print value  

}

output:

4

You might be interested in
When should you create an outline?
DIA [1.3K]

Answer:

hope you like it

Explanation:

Writing an outline can take place at any time during the writing process. Although it is most commonly used before beginning to write or doing research, this process can also take place during or after writing your paper to make sure your points are organized and make sense.

An outline is a first step for writing: a general, unfinished plan that you will use as a guideline in writing, not a finished product ready to publish. You should use it when you prepare to write a rough draft, before you started writing.

8 0
3 years ago
Hashing algorithms are used on evidence files to uphold the chain of custody in an investigation. Which of the following is NOT
raketka [301]

Answer:

C. DAT-1

Explanation:

Chain of custody is applied when examining digital evidence and checking for proof that no alterations have been made to the document. It ensures that the original piece of digital evidence which could be in text, image, video, or other electronic formats, is preserved and protected from alterations. Hashing algorithms which are mathematical computations that help to condense files are applied during this procedure.

Common hashing algorithms applied, include;  the message digest 4, secure hashing algorithms 1, 2, 256, 224, 512, etc. The message digest 4 is used to evaluate why a particular piece of evidence was handled by an individual. This is further authenticated by examining the fingerprint.

4 0
3 years ago
What type would the object X be in the following statement:
Y_Kistochka [10]

Answer:

Boolean

Explanation:

If statement condition always returns true or false,which is a boolean data type.

X is true or false

it maybe a variable or an expression.

5 0
2 years ago
Read 2 more answers
Im trying to type in answers but where the text box is supposed to be it says unlock answers. What does that mean?
borishaifa [10]
You may have to pay or sign up for the text box or if it is a computer program you may need to get the full version of the software if it is a trial
3 0
2 years ago
What conversion factor should be used to convert from meters to Gigameters?
hodyreva [135]
Meters * 1,000,000,000 = gigameters
5 0
2 years ago
Other questions:
  • Write a Scheme function called "sum" which takes an input function func and a nonnegative number n and outputs the value
    10·1 answer
  • The excessive use of the internet and the web for personal use at work is sometimes called ____ .
    7·2 answers
  • A machine is classified as a compound machine if it?
    8·2 answers
  • CRM systems provide an organization with an important element: all employees of the company who directly or indirectly serve a c
    9·1 answer
  • A certain manager makes the following statement "Our internet company is in business for the money, making profits, and making t
    13·1 answer
  • Alice is working on a web page to attract the maximum number of people to join her cause. She wants to inform people about the b
    12·1 answer
  • Inputting a range of numbers comprising a batch and then inputting each serially numbered document is characteristic of the cont
    11·1 answer
  • Some of y'all make me lose braincells with your questions
    10·2 answers
  • Which example best demonstrates an impact of computers on the economy?
    6·1 answer
  • Simplest way to start baking career is to attend_______.<br><br><br><br>​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!