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]
2 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]2 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
Hey, wanna pair our account on Brainly so we can share the perks? https://brainly.com/invite/8db681239ab5027e03b097bcded13755?ut
sashaice [31]

Answer:

Explanation:

NO Thx

8 0
3 years ago
Read 2 more answers
By what decade were books readily available to the public across the United States and Europe?
Westkost [7]

Answer:

1690's hope i could help!

5 0
2 years ago
We canconnect  two or more computer together using cables true or false​
jekas [21]

This is true for most modern computers

8 0
2 years ago
What is an XML-based open standard for exchanging authentication and authorization information and is commonly used for web appl
nalin [4]

Answer:

SAML.

Explanation:

SAML seems to be an accessible standardized XML-based for some of the sharing of validation and verification details and has been generally implemented for the web apps and it seems to be a design that would be SSO. Verification data is shared via XML documentation which are securely signed. So, the following answer is correct according to the given scenario.

4 0
2 years ago
The ____ command will confirm the system directory that you are currently in
stira [4]
Im pretty sure the answer is PWD
7 0
3 years ago
Other questions:
  • What is one visual indication that a usb port can be used to charge a mobile device?
    13·1 answer
  • Maya enjoys connectedWith her friends and social media apps but one of her friends post a lot of stuff that my thinks it’s annoy
    14·1 answer
  • Please Help!! How to code this in Python?
    11·1 answer
  • Has anyone on here heard from lilkoadkmillines?
    10·1 answer
  • Which option is referred to by the Reports Due tag?
    7·1 answer
  • What are some things you can do to clean up your digital footprint.
    9·1 answer
  • What is speaker?.....​
    13·1 answer
  • What does playstation network is currently undergoing maintenance?.
    15·1 answer
  • Data mining requires specialized data analysts to ask ad hoc questions and obtain answers quickly from the system. select one: t
    12·1 answer
  • an engineer is writing a web application that requires some user input. the engineer has put a submit button on their page and n
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!