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
zaharov [31]
2 years ago
12

Using the programs given in the appendix of this lab, write two programs: • One that will use a Linear search to find the amount

of time it takes to find (or not find) the number: 99,999,999. • One that will use a Binary search to find the amount of time it takes to find (or not find) the number: 99,999,999. • The only difference between the two programs will be the search function. • Record the amount of time it takes to do the Binary Search as well as the Linear search. • Run the test at least 5 times each.
Computers and Technology
1 answer:
miss Akunina [59]2 years ago
6 0

Answer:

// C++ code to linearly search x in arr[]. If x  

// is present then return its location, otherwise  

// return -1  

#include <iostream>  

using namespace std;  

int search(int arr[], int n, int x)  

{  

int i;  

for (i = 0; i < n; i++)  

 if (arr[i] == x)  

  return i;  

return -1;  

}  

int main(void)  

{  

int arr[] = { 2, 3, 4, 10, 40 };  

int x = 10;  

int n = sizeof(arr) / sizeof(arr[0]);  

int result = search(arr, n, x);  

(result == -1)? cout<<"Element is not present in array"

   : cout<<"Element is present at index " <<result;  

return 0;  

}  

You might be interested in
Write an application that prompts a user for a month, day, and year. Display a message that specifies whether the entered date i
gizmo_the_mogwai [7]

Answer:

Following is given the code with all necessary description given as comments in it. I hope it will help you!

Explanation:

4 0
2 years ago
Which retouching action is unethical?
e-lub [12.9K]

Answer:

B.) removing the saturation in a photograph intended as a magazine cover page

7 0
2 years ago
Software that interprets commands from the keyboard and mouse is also known as the what?
7nadin3 [17]
Out of the ones that you mention, the correct answer should be 
<span> Operating system</span>
3 0
3 years ago
Read 2 more answers
true false the if statement causes one or more statements to execute only when a boolean expression is true
poizon [28]

Answer:

True

Explanation:

I am a coder myself and I say this is true because it executes it if the listed statement or variable is true. This is also the same for the while loop.

8 0
2 years ago
Where Can I Get Actual Microsoft AZ-900 Exam Questions?
Pachacha [2.7K]

Answer:

Pls check the site "examtopics"

U fill find ur questions there

8 0
3 years ago
Other questions:
  • Carlos own a hardware store.He currently is not using any software to track what he has in the store. .In one to two sentences,
    10·1 answer
  • An application needs to calculate sales tax for purchases. You decide to simplify the code by putting the sales tax calculation
    9·1 answer
  • Select the correct answer.
    11·1 answer
  • Concentric circles on a disk platter where data is stored;________
    8·1 answer
  • What is the maximum current that should be allowed in a 5.0w 220 resistor?
    12·1 answer
  • You’re having trouble connecting to the Internet so you call your Internet service provider for help. They need to know the perm
    15·1 answer
  • How is a digital representation of analog data a form of abstraction? Why is the quality of the photo, music, etc better when mo
    11·1 answer
  • What is composition
    13·1 answer
  • Remember not to use tools that are ________ in any way.
    5·1 answer
  • This rights protected document cannot be opened because the rights management feature has been disabled on your machine by Polic
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!