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
How can you stretch or skew an object in paint
Marat540 [252]

Here's link to the answer:

tinyurl.com/wpazsebu

3 0
3 years ago
What is the definition of legal intrusion
AleksAgata [21]
My answer -

intrusion of rights, right of privacy, trespass

P.S

Happy to help you have an AWESOME!!! day ^-^
5 0
2 years ago
A large population of ALOHA users manages to generate 50 requests/sec, including both originals and retransmissions. Time is slo
krok68 [10]

Answer:

The answer is below

Explanation:

Given that:

Frame transmission time (X) = 40 ms

Requests = 50 requests/sec, Therefore the arrival rate for frame (G) = 50 request * 40 ms = 2 request

a) Probability that there is success on the first attempt = e^{-G}G^k but k = 0, therefore Probability that there is success on the first attempt = e^{-G}=e^{-2}=0.135

b) probability of exactly k collisions and then a success = P(collisions in k attempts) × P(success in k+1 attempt)

P(collisions in k attempts) = [1-Probability that there is success on the first attempt]^k = [1-e^{-G}]^k=[1-0.135]^k=0.865^k

P(success in k+1 attempt) = e^{-G}=e^{-2}=0.135

Probability of exactly k collisions and then a success = 0.865^k0.135

c) Expected number of transmission attempts needed = probability of success in k transmission = e^{G}=e^{2}=7.389

6 0
3 years ago
8. What is the order of growth execution time of the push operation when using the LinkedStack class, assuming a stack size of N
velikii [3]

The order of growth execution time of the push operation when using the LinkedStack class, assuming a stack size of N is; O(1)

<h3>Understanding Computer Programming Language</h3>

Let Top be the position of last element inserted in Array.

For Push operation, the process is as follows;

if(Top == last index of Array) {

Printf(“Stack Overflow”)

} else {

Top = Top + 1

a[Top] = element you want to insert

}

Read more about Computer Programming at; brainly.com/question/22654163

8 0
2 years ago
Any fact or set of facts, such as the words in a letter to a friend or the notes in a song, can become computer ____.
Alina [70]

I think the answer is... data

3 0
3 years ago
Other questions:
  • Which of the following is an example of a good listening skill? A. Replying to the caller as "you" rather than using his or her
    9·2 answers
  • Match the items.
    15·1 answer
  • A user can easily move to the end of a document by pressing the _____ key combination.
    10·2 answers
  • Compare and contrast the following network types: Personal Area Network (PAN) Local Area Network (LAN) Metropolitan Area Network
    14·1 answer
  • The posterior auditory stream terminates in the ________ and is involved in ________.
    12·1 answer
  • A forensic investigator at a crime lab is performing a forensic analysis of a hard drive that was brought in by state troopers.
    10·1 answer
  • Which technique helps you look confident as a speaker?
    15·1 answer
  • Which act requires financial institutions to ensure the security and confidentiality of customer data and mandates that data mus
    8·1 answer
  • WILL GIVE MORE POINTS, PLEASE HELP!!!
    11·1 answer
  • B) What is system software? Write its importance.​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!