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
Which tool relies on the logged on user's certificate details to encrypt or decrypt files and folders? powershell bitlocker encr
grigory [225]
The tool relies on the logged on user's certificate details to encrypt or decrypt files and folders is the encrypting file system (efs).
It gives filesystem-level encryption as part of the improvement made on Microsoft Windows in version 3.0 of NTFS. This technology allows files to be visibly encrypted to secure confidential data from unsecured access to the computer. 
3 0
4 years ago
Keisha wants to change the font color on the 1st and 3rd bullet items on slide 6 of her allied health presentation. what is the
Mice21 [21]
Is to tie them up together with a
7 0
4 years ago
clinical outcomes and survival differences between primary, secondary and concomitants carcinoma in situ of urinary bladder trea
8_murik_8 [283]

The summary of the research - clinical outcomes and survival differences between primary, secondary and concomitants carcinoma in situ of urinary bladder treated with BCG Immunotherapy is given below.

<h3>What is the summary of the above research?</h3>

Urinary bladder carcinoma in situ (CIS) is a flat, high-grade, and aggressive form of urothelial cancer with a high likelihood of development to muscle-invasive illness and metastatic dissemination.

The study's goal was to compare the clinical histories and survival rates of primary, secondary, and concurrent CIS of the bladder.

Learn more about Immunotherapy at brainly.com/question/14493516

#SPJ1

6 0
1 year ago
Read 2 more answers
Pseudocode of creating a program to convert to IEEE 754 to a real number
Eduardwww [97]

Answer:

  • Step1: Check If the number is Positive or Negative.  
  • Step2: If it is positive then save the sign of it as 0.  
  • Step3: If it is negative then save the sign of it as 1.
  • Step4: Covert the negative number to Positive.
  • Step5: Convert the IEEE 754 to Binary.
  • Step6: convert the integer part into binary form  
  • Step7: Convert fractional part into binary form
  • Step8: To convert Integer part, Devide the number by 2 and note down the reminder and Keep deviding unless dividend is less than 2
  • Step9: copy all the reminders together
  • Step10: Multiply decimal part by 2 unless fractional part is 0.
  • Step11: By noting down integral part, keep multiplying decimal part by new value of 2 untill perfect number is reached.
  • Step6: Find the Mantissa.
  • Step7: Concatinate the Sign, exponent and the mantissa.

Explanation:

For Example : 20.75

First step (converting 50 (in base 10) to binary):

  • No is Positive
  • By dividing 20 by 2, which gives 10 with no remainder 0.
  • Now Devide 10 by 2, which gives 5 with a remainder of 0.
  • Now Devide 5 by 2, which gives 2 the reminder as 1
  • Now Devide 2 by 2, which gives 1 with reminder as 0
  • Now devide 1 by 2, which gives 0 with reminder as 1
  • We read the result from bottom to top  which is 10100

Second part is to convert 0.75 to binary:

  • We have to multiply 0.75 by 2, which gives 1.5. We keep only the integer part, which is 1.  
  • Now, we do 1.5 - 1, which gives 0.5. Now, We multiply 0.5 by 2, which gives 1.  
  • Now we do 1 - 1, which gives 0.
  • Reading from Top to bottom will give 110

Final Answer is : 10100.110

8 0
3 years ago
A _____ is a modeling tool used in structured systems analysis and design (SSAD) analysis model that helps break down a complex
Shalnov [3]

A <em>"DATA FLOW DIAGRAM"</em> is a modeling tool used in structured systems analysis and design (SSAD) analysis model that helps break down a complex process into simpler, more manageable, and more understandable subprocesses

8 0
4 years ago
Other questions:
  • Laura is using studio lighting while photographing a model. The four elements that she will use in studio lighting are hot light
    10·1 answer
  • Consider the following code which deletes all the nodes in a linked list. void doublyLinkedList::destroy() { nodeType *temp; //p
    14·1 answer
  • Why is it important to use the binomial nomenclature system?
    6·1 answer
  • 8. When requesting a review of a denied claim, it is required to send a _______________ with the claim.
    10·1 answer
  • Knowledge management software helps companies preserve the knowledge gained through the use of information so that future users
    15·2 answers
  • _______and ________ enables computers to communicate and it can pass information between two networks.
    15·1 answer
  • If you created a variable called name, what data type would that value be?
    15·2 answers
  • HELP ME PLEASE
    8·1 answer
  • How do web-based applications and websites differ? (2 points)
    13·1 answer
  • The set Canvas.PaintColor to block sets the paint color for the _____ .
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!