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
Svet_ta [14]
3 years ago
11

Consider a binary-search method in an array that reports whether an object is in the array. The documentation indicates that the

caller must pass in a sorted array or the results are unspecified. According to strict design-by-contract, who is responsible for checking that the array is sorted
Computers and Technology
1 answer:
inn [45]3 years ago
5 0

#include<iostream.h>

#include<conio.h>

void sort(int A[], int N)

{int I,J,tmp;

for(I=0;I<N;I++)

{for(J=0;J<N;J++)

{if(A[J]>A[J+1])

{tmp=A[J];A[J]=A[J+1];A[J+1]=tmp;}}}}

void main()

{int a[15],I,n,l,u,sh,mid,k=0;

clrscr();

cout<<”Enter the array size”;

cin>>n;

l=0;u=n-1;

cout<<”\nEnter the array elements”<<endl;

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

cin>>a[i];

sort(a,n);

cout<<”\nEnter search element”;

cin>>sh;

cout<<”\nNow, applying N=Binary Search”<<endl;

while(l<=u)

{mid=(l+u)/2;

If(a[mid]>sh)

u=mid-1;

if(a[mid]<sh)

l=mid+1;

if(a[mid]==sh){k=1;break;}}

if(k==1)

cout<<”\n Element is present at “<<(mid+1)<<endl;

else

cout<<”\n Element not found”;

getch();

}

<u>Explanation:</u>

Binary Search is a type of search method which is more effective and takes more traversals than the linear search. It compares the each element to the middle element. If the element is found, it gives the position otherwise it will give no result.

You might be interested in
Which of the following are correct? I. Hold the middle mouse button to rotate the model on the screen. II. To pan the model, hol
evablogger [386]

Answer:

II and III are correct

Explanation:

The software that the question is referring to here is the computer-aided design (CAD) software called Inventor by Autodesk.

I. Hold the middle mouse button to rotate the model on the screen. False

This will pan the model instead of rotating.

II. To pan the model, hold down the Ctrl key and the middle mouse button. True

Some versions need you to hold down the ctrl key and the middle mouse button to pan, while others is just the middle mouse button then you drag the mouse around. The middle mouse is the scroll wheel on most mice today. You basically, just hold down the scroll wheel as you move the mouse to pan the model.

III. Use the mouse scroll wheel to zoom in and out of the model. True

To zoom in or out, one will need to rotate the mouse scroll wheel forward to zoom in and backward to zoom out.

 

8 0
3 years ago
Given the following output from /etc/fstab, which filesystems will be automatically checked on boot by the fsck command? [BEGIN
leva [86]

Answer:

Details below

Explanation:

From the following output we will get: /, /dev/pts, and /dev/shm while fsck is running automatically at boot for all filesystems

6 0
3 years ago
What command is used to add a reflection or an outline to text
WARRIOR [948]

text effects, and typography.

6 0
3 years ago
In order for a computer to pass the ________, a human should have a conversation with it and not be able to tell if it was a mac
Katena32 [7]

The test that a computer needs to pass after a human's conversation with it and not be able to tell if it was a machine or a human is; Turing Test

<h3>Test of Computers</h3>

The correct answer to the blank portion of the question is Turing test. This is because Turing Test is a test of a computer's ability to exhibit intelligent behavior that is equivalent to, or indistinguishable from, that of a human's behavior.

Finally, If the evaluator cannot reliably tell the computer from the human, the machine is said to have passed the test.

Read more about Test of Computer at; brainly.com/question/21283135

8 0
2 years ago
Please explain what Level 5 Automation is and give 2 examples of the technology.
arsen [322]

Level 5 ( Full Driving Automation ) Level 5 cars won't even have steering wheels or acceleration / braking pedals . They will be free from geofencing , able to go anywhere and do anything that an experienced human driver can do .

Pls follow me and Mark as brainlest!!! :-)

8 0
3 years ago
Other questions:
  • Rose has a list of two columns of information separated by tabs. She wants to input this information into a table. What is the f
    15·2 answers
  • How is a ink pen better than a digital pen.
    8·1 answer
  • If you wanted to look up an article from the Chicago Tribune the best place to start would be
    7·1 answer
  • Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that dea
    12·1 answer
  • The blank provides access to the internet May also be internal ??
    14·1 answer
  • Which popular file format loses some of the information from the image? JPEG TIFF RAW NEF
    12·1 answer
  • Please help. will give u brainliest!! khan academy computers and the internet!!
    12·1 answer
  • Compare and contrats the vain digestive system from the human digestive system.​
    10·1 answer
  • How do you get lugia in pokemon alpha saphire
    6·1 answer
  • you are currently logged in using the badams account. you want to view the contents of the /etc/inittab file, but you are not al
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!