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
What is meant by ‘LASER’?
Zanzabum
Light Amplification by Stimulated Emission of Radiation
5 0
3 years ago
Read 2 more answers
What type of game is LEAST LIKELY to need a structured narrative?
VladimirAG [237]

Answer:

Probably a sports game

Explanation:

A role-playing means acting it out, so you need to explain the life with a structured narrative.

An adventure game needs lots of background, so you need to fill that in with a structured narrative.

A sports game revolves solely around sports, so you only need to know how to play the game and/or sport, so no structured narrative is needed.

An fps game needs a structured narrative in that it is similar to an adventure game and needs background.

Let me know if I was right! Hope this helped. :)

5 0
3 years ago
What are 3 examples of Chassis Wiring?
Roman55 [17]

Answer:

.

Explanation:

5 0
3 years ago
The purpose of a method's postcondition is to
anyanavicka [17]
The answer that would best complete the given statement above would be option 5. The purpose of a method's postcondition is to describe the conditions that are true when the method completes. On the other hand, precondition describes the conditions that are true before the method is complete. Hope this helps.
7 0
3 years ago
A user wants to visualize a highly complex 3D model using a Virtual Reality headset.
Lyrx [107]

The best way for an end user to visualize a highly complex 3D model using a Virtual Reality headset is to: A) use any headset and increase the bandwidth of the Wi-Fi connection.

<h3>What is Virtual Reality (VR)?</h3>

Virtual Reality (VR) can be defined as a computer technology through which virtual images of any physical environment (realities) and human-machine interactions are displayed, especially through the use of various computer technologies and wearables.

<h3>The elements of Virtual Reality (VR).</h3>

Some of the elements of Virtual Reality (VR) include the following:

  • Life interaction
  • Self projection
  • Telexistence
  • 3D space or model.

In this context, we can infer and logically deduce that Virtual reality is a  computer technology which is designed and developed to simulate a three-dimensional (3D) environment through which end users can explore and interact.

In conclusion, the best way for an end user to visualize a highly complex three-dimensional (3D) model using a Virtual Reality headset is to use any headset and increase the bandwidth of the Wi-Fi connection.

Read more on Virtual Reality here: brainly.com/question/26705841

#SPJ1

6 0
2 years ago
Other questions:
  • If it can be applied, the least-damaging recovery option is ________.
    10·1 answer
  • In the U.S. highway numbering system, north-south routes have
    9·2 answers
  • Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followe
    13·1 answer
  • What impact did congress declaration on copyrighting sound recordings have on home recording and record sales
    8·2 answers
  • c++ You are given an array A representing heights of students. All the students are asked to stand in rows. The students arrive
    5·1 answer
  • Which of these is a method of selecting multiple items in Impress or PowerPoint? A. holding down the Ctrl key while clicking ite
    9·2 answers
  • Help me with this, please. Are vacuum cleaners, Cd players, and telephones considered computers? Do they store any data or proce
    8·2 answers
  • Explain the role of a computer in education​
    9·1 answer
  • 1. Software that is designed to intentionally cause harm to a device, server, or network is A. outware B.loggerware C.
    12·1 answer
  • The director of security at an organization has begun reviewing vulnerability scanner results and notices a wide range of vulner
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!