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
The term that refers to the standard computer language for creating web pages is called:
Pavel [41]

Answer:

Language programming Web's programming language

Explanation:

6 0
4 years ago
Which server-based authentication protocol would be best for an organization that wants to apply authorization policies on a per
BARSIC [14]

Answer:

TACACS+

Explanation:

TACACS+ or terminal access controller access-control system plus is an open standard protocol developed by Cisco. It encrypts all communication in a network ( including the password and data sent) and supports a separate authentication, authorisation and accounting policies for access to a centralised database.

It also uses the transport layer protocol TCP for a reliable data communication.

6 0
3 years ago
Info, and Contact Us. She will create a hierarchy of page elements and revise the style sheets. In this case, the Home page cont
Alchen [17]

Answer:

link

Explanation:

3 0
3 years ago
In DTP, a good rule of thumb is to use as many special effects as you need to make your documents look interesting.
Margarita [4]
It all depends back on who youre present it t

younger ages (Primary-Middle),
Its Ok to use plenty of special effects, but dont ovedue your DTP with effects, so that they still can get the point.

Older ages (High & above)
Older people usually more serious than older ages to pursue their careers, so less effect, more points


5 0
3 years ago
Classified Computer by their age​
andreyandreev [35.5K]

Answer:

The answer is below

Explanation:

Classification of computers by age are the following:

First generation from 1940 to 1956. For example, ENIAC using a vacuum tube

Second generation from 1956 to 1963. For example, IBM 7070 using transistor

Third generation from 1964 to 1971. For example, this type of computers use an Integrated circuit

Fourth generation from 1972 to 2010. For example, IBM 5100 using a microprocessor.

Fifth-generation from 2010 to present For example IBM Watson, using Artificial intelligence.

5 0
3 years ago
Other questions:
  • your grandmother tells you a dollar doesn’t go as far as it used to. She says the “purchasing power” of a dollar is much less th
    6·1 answer
  • Jackson builders is constructing new homes in the Parkway subdivision.The company needs the logic for an application that ncalls
    13·1 answer
  • The purpose of the _____ element is used to configure the footer information ona web page document
    6·1 answer
  • The next page and previous page buttons allow you to navigate through a worksheet while in print preview mode.
    6·1 answer
  • 3. The combination of keys that we should press to select all document is
    14·1 answer
  • Which is a difference between the systems development life cycle (SDLC) and extreme programming (XP)?
    7·1 answer
  • To encourage good grades, Hermosa High School has decided to award each student a bookstore credit that is 10 times the student’
    11·1 answer
  • Convert the following Base 2 (binary) numbers to base 10(decimal):<br> 11101<br> 1010101
    13·1 answer
  • An alarm clock draws 0.5 A of current when connected to a 120 volt circuit. Calculate its resistance.
    10·1 answer
  • Write 10 sentences of your own and underline the verb.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!