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]
3 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]3 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
Chris is responding to a security incident that compromised one of his organization's web servers. He believes that the attacker
Aloiza [94]

The cybersecurity objective that the above attack violate is known as Integrity.

<h3>What is Cybersecurity aims?</h3>

Their objectives is majorly to protect any computers system, networks, and other kinds of software programs from any type of cyber attacks.

Note that The cybersecurity objective that the above attack violate is known as Integrity as they are not the kind of people that keep to their words.

Learn more about cybersecurity from

brainly.com/question/12010892

#SPJ1

3 0
2 years ago
What will be the output of the statement?<br> System.out.println(2*4*(8+3)-9%7);
Lapatulllka [165]

Answer:

87.37

Explanation:

(2*4*(8+3)-9%7)

(8*(8+3)-9%7)

8*(11)-9%7

88-8%7

88-0.63

87.3

7 0
4 years ago
When implementing a 1:1 relationship, where should you place the foreign key if one side is mandatory and one side is optional?
777dan777 [17]

Answer:

When implementing a 1:1 relationship, the foreign key should be placed on the optional side if one side is mandatory and one side is optional.  

When this is implemented, the foreign key should be made mandatory.

Explanation:

A foreign key (FK) is a primary key (PK) in relational databases.  It is used to establish a relationship with a table that has the same attribute with another table in the database.  A mandatory relationship exists when the foreign key depends on the parent (primary key) and cannot exist without the parent.  A one-to-one relationship exists when one row in a data table may be linked with only one row in another data table.

5 0
3 years ago
Which is the best choice <br> A.<br> B.<br> C.<br> D.
Tanya [424]
The $ sign denotes a row or a column as absolute. Since the rows are numbers (columns are letters), you're looking for an answer with a $ sign in front of a number.

That's answer D I would say.
5 0
4 years ago
What are the characteristics needed in a secure hash function?​
viktelen [127]
Cryptographic hash functions are utilized in order to keep data secured by providing three fundamental safety characteristics: pre-image resistance, second pre-image resistance, and collision resistance.
8 0
3 years ago
Other questions:
  • Which two computer peripherals are connected to the computer through a port?
    9·1 answer
  • A Windows systems administrator should use the Administrator account ________.a. As little as possible, and only when needed b.
    15·1 answer
  • ​What file system below does not support encryption, file based compression, and disk quotas, but does support extremely large v
    10·1 answer
  • Which of the following would help a photographer keep from dropping a camera? - - Rain hood
    6·2 answers
  • Based upon what you know
    5·1 answer
  • What is a two content slide​
    7·1 answer
  • A ________ database state is one in which all data integrity constraints are satisfied
    15·2 answers
  • Describe the objectives of e-commerce ?​
    5·1 answer
  • What is the example of HTML?​
    13·1 answer
  • It means fruit- trees garden.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!