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
kykrilka [37]
3 years ago
13

From the binary search algorithm, it follows that every iteration of the while loop cuts the size of the search list by half.

Computers and Technology
1 answer:
Colt1911 [192]3 years ago
6 0

Answer:

True: In binary search algorithm, we follow the below steps sequentially:

Input: A sorted array  B[1,2,...n] of n items and one item x to be searched.

Output: The index of x in B if exists in B, 0 otherwise.

  1. low=1
  2. high=n
  3. while( low < high )
  4.  {      mid=low + (high-low)/2
  5.         if( B[mid]==x)
  6.          {
  7.             return(mid)  //returns mid as the index of x
  8.           }
  9.          else
  10.          {
  11.              if( B[mid] < x)      //takes only right half of the array
  12.               {
  13.                 low=mid+1
  14.               }
  15.              else               // takes only the left half of the array
  16.               {
  17.                high=mid-1
  18.               }
  19.           }
  20.  }
  21. return( 0 )

Explanation:

For each iteration the line number 11 or line number 15 will be executed.

Both lines, cut the array size to half of it and takes as the input for next iteration.

You might be interested in
Coloumn1; Criteria1: Average of best three marks (CA); CA&gt;=40
Nikitich [7]

Answer:

Please check the attachment.

for the assembly language program the jump and move keywords have been used to establish the if else ladder.

Also for the best three marks, we need to store the three theory and two practical marks in an array, and then we can sort it to get the best three marks to find the CA. and then from initial array, we can find the last two practical test parks, and find their average.

Rest of the calculation is as being mentioned in the image. Also, in the image we have 2 practicals. We need to count two instead of three there, and rest is as shown.

Explanation:

The answer does not require any further explanation.

5 0
3 years ago
Explain what happens if you try to open a file for reading that does not exist.
ZanzabumX [31]

Answer:

Exception is thrown and the file is created with 0 length.

Explanation:

While opening a file there is an error occur which shows the file does not exist that means an  exception is thrown.

And this error can be occur when the size of the file is very very low means the file is a size of 0 length. So to avoid this error we have to exceed its length from the zero length.

8 0
3 years ago
The Earth's _______ is ductile overall, tending to flow very slowly and deform in a _______ manner.
kipiarov [429]

<span>The asthenosphere is a part of the upper mantle just below the </span>lithosphere<span> <span>that is involved in </span></span>plate tectonic movement<span> <span>and </span></span>isostatic<span> <span>adjustments. The lithosphere-asthenosphere boundary is conventionally taken at the 1300 °C </span></span>isotherm<span>, above which the mantle behaves in a rigid fashion and below which it behaves in a </span>ductile<span> fashion. a</span><span>nd </span>flows very slowly, in a manner<span> similar to the ice at a bottom of a glacier.</span>

5 0
3 years ago
Read 2 more answers
cout &lt;&lt; "Part 1" &lt;&lt; endl; // Part 1 // Enter the statement to print the numbers in index 4 and index 9 // put a spac
Margarita [4]

Answer and Explanation:

#include <iostream>

using namespace std;

int printEven(int array[],int n)

{

int count=0;

for(int i=0;i<n;i++)

{

if(array[i]%2==0)

{

count++;

cout<<array[i]<<" ";

}

}

return count;

}

void printAll(int array[],int n)

{

for(int i=0;i<n;i++)

{

cout<<array[i]<<" ";

}

}

int computeTotalOdds(int array[],int n)

{

int count=0;

for(int i=0;i<n;i++)

{

if(array[i]%2!=0)

{

count++;

 

}

}

return count;

}

int main()

{

int array1[20] = {3, 18, 1, 25, 4, 7, 30, 9, 80, 16, 17};

int numElements = 11;

cout << "Part 1" << endl;

cout<<array1[4]<<" "<<array1[9];

cout << endl;

cout<<array1[0]<<" "<<array1[8];

cout << endl;

array1[2]=12;

cout << "\nPart 2" << endl;

printAll(array1,numElements);

 

cout << "\nPart 3" << endl;

int evens;

evens=printEven(array1,numElements);

 

 

 

 

// This will print the number of evens in the array.

cout << endl << evens;

 

cout << "\nPart 4" << endl;

 

int total;

 

total=computeTotalOdds(array1,numElements);

cout << endl << total;

 

return 0;

}

3 0
2 years ago
Anyone knows the answer for 6.1.4 Happy Birthday! codehs
Neko [114]

cvm is good cvm is great

7 0
2 years ago
Other questions:
  • Windows uses a graphical user interface (GUI), which means: a user can carry out commands by clicking, dragging, or otherwise ma
    6·1 answer
  • Which of the following statements is false? a. Classes (and their objects) encapsulate, i.e., encase, their attributes and metho
    15·1 answer
  • The item that is clicked in a JList can be retrieved using the _____ method of JList.
    8·1 answer
  • . Database connectivity software is also known as:
    11·1 answer
  • B) If you send me an email, then I will finish my program. If you do not send me an email, then I will go to sleep early. Theref
    10·1 answer
  • In an information systems framework, ________ is the bridge between the computer side on the left and the human side on the righ
    14·1 answer
  • [This is on Edhesive (coding and programming)]
    8·2 answers
  • Why is operating system important software for computer?give 3 reasons
    8·1 answer
  • What is an aspect ratio?
    6·1 answer
  • Tom wants to find a number so that the sum of the digits of a two-digit number is 7. When reversing the digits, the number shoul
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!