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
Compare and contrast between Client/Server and Peer-to-Peer networks. What are some of the business benefits of using such netwo
fgiga [73]
Client/Server and Peer-to-Peer networks are the two major network architecture models in use today. They each have advantages and disadvantages that can be used to benefit a particular outcome.

Briefly, the client/server model relates to one or many client performing relatively simple requests, which are then executed by a server. The server is performing more complex tasks, and often interacting with many clients simultaneously. Examples of client/server models include most websites, including the Brainly page you are running right this instant. Your web browser is acting as a client, and the Brainly.com website is running as a web server. It receives simple requests or information from your browser, such as clicking on a question or text typed by your keyboard, and then acts on this information by consulting a database, returning values, or returning a whole new web page to your browser. The client/server model is very powerful in business as it allows powerful and secure server-side processing and relatively simple clients. Office 365 that runs all microsoft office suites such as word and excel in a web browser on 'the cloud' is an example of a highly sophisticated client/server architecture.

By contrast, peer-to-peer networks are a distributed architecture of equals. Instead of a simple client and complex server, all clients are equals and link together to form nodes on a distributed network. There is no central control (server) and each node acts as a client and server to other nodes. This is also an extremely powerful network; as there is no central control it is difficult to shut down a peer-to-peer network. Taking out one node will not break the network in comparison to the client/server architecture where if the server goes down, services halt. Prime examples of famous peer-to-peer networks are the Bitcoin network and similar cryptographic currency networks, and music and file sharing networks such as Torrents. The torrent tracker websites are client/server however once a torrent is loaded into a torrent downloading application, the file is collectively downloaded from hundreds of 'peers' across the world as part of the torrent peer-to-peer network.


3 0
3 years ago
Problem 1. MST - Prim's and Kruskal's algorithms
Juli2301 [7.4K]
Or maybe not Encryption converts the data in a database to a format that is indecipherable to unauthorized users who attempt to bypass the DBMS.

a. True
b. False
7 0
3 years ago
Next, Sue decides to embed a chart from Microsoft Word. She copies and pastes data from a table that she has already created in
antoniya [11.8K]

Answer:

Its D

Explanation:

On Edg

8 0
3 years ago
Which of the following statements is true?
jeka57 [31]

Answer: Constructors can specify parameters but not return types.

Explanation:

public class Student {

 int roll_no;

 public Student(int a) {

   roll_no = a;

 }

public static void main(String[] args) {

   Student abs = new Student(10);

   System.out.println(abc.roll_no);

 }

}

In the above code we have illustrated the working of constructors. We have a class with the name Student. then a constructor is created of the class called as the class constructor. In the main we create an object of the class and with this object we invoke the constructor and also pass a parameter. Here in the code we are passing the roll no of the student.

So we can say that constructor is called during the runtime when the object created invokes the constructor so a constructor can have many arguments but it does not have a return type.

7 0
3 years ago
Which of the following statements accurately describes the early history of digital recording?
Alchen [17]
I would like to say that it was D. If I am not correct, try asking this in history.
6 0
3 years ago
Other questions:
  • Write a function named delete Letter that has 2 parameters. The first parameter is a string, the second parameter is an integer.
    11·1 answer
  • The elements in a string type array will be initialized to ____.?
    10·1 answer
  • Letter Frequency Write a function that will take a string and return a count of each letter in the string. For example, "my dog
    5·1 answer
  • Object-Oriented Programming (Using Java Language)
    11·1 answer
  • Will give brainly if answer all or my questions
    8·1 answer
  • What are the factors affecting the life of ballast? Explain.​
    15·1 answer
  • February 1995, Kevin Mitnick was arrested. While on parole was he allowed to have a phone or computer?
    6·2 answers
  • You are writing a program to help compare two sports teams. A sample member of the list scores is [2. 5] where your team scored
    5·2 answers
  • Betty was sitting at a coffee shop reading her favorite book. She heard an explosion nearby. In a few, she could hear ambulance
    7·2 answers
  • Do you want my hero academia?<br><br><br><br><br><br> if so, who's your favorite character :&gt;
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!