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]
3 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]3 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
Create a class named Circle with fields named radius, diameter, and area. Include a constructor that sets the radius to 1 and ca
REY [17]

Answer:

The code for this class is shown in the explanation section

Explanation:

public class Circle {

   private double radius;

   private double diameter;

   private double area;

   public Circle(double radius, double diameter, double area) {

       this.radius = 1;

       this.diameter = diameter;

       this.area = area;

   }

   public void setRadius(double radius) {

       this.radius = radius;

       diameter = radius*2;

       area= Math.PI*(radius*radius);

   }

   public double getRadius() {

       return radius;

   }

}

6 0
3 years ago
Write a Python function that takes as input a list, A, and returns two lists L and G. L constains all numbers in A, which are no
DiKsa [7]

Answer:

In Python:

def split(A):

   L=[]; G=[]

   for i in range(1,len(A)):

       if (A[i] != A[0] and A[i] < A[0]):

           L.append(A[i])

       if (A[i] != A[0] and A[i] > A[0]):

           G.append(A[i])

   return L, G

Explanation:

This defines the function

def split(A):

This initializes the L and G lists

   L=[]; G=[]

This iterates through the original list A

   for i in range(1,len(A)):

This populates list L using the stated condition

<em>        if (A[i] != A[0] and A[i] < A[0]):</em>

<em>            L.append(A[i])</em>

This populates list G using the stated condition

<em>        if (A[i] != A[0] and A[i] > A[0]):</em>

<em>            G.append(A[i])</em>

This returns the two lists L and G

   return L, G

8 0
2 years ago
Which tool ia used to create the world wide web?
avanturin [10]

Answer:

HTML

Explanation:

HTML is the correct answer

5 0
3 years ago
Your agile team only has one database developer. So the other developers finish their tasks and then wait for their work to be I
Novosadov [1.4K]

Members of an Agile development team often agrees on what tasks to work on and they do it together. The one possible solution to this challenge is to Have the database developer train the rest of the team so there are fewer handoffs.

Agile development team often works together as a team. They as team discuss the task yo take, when it will take place etc.

This team is all about communication, teamwork, problem-solving etc.

Conclusively, A task should be completed by one member on the team, but the team may choose to pair up when doing the work.

Learn more from

brainly.com/question/24383225

See full question below:

Your agile team only has one person who knows how to develop database software. So the other developers finish their tasks and then wait for their work to be Integrated into the database. This creates a pile of backed up work for the database developer. But it also means that the other developers must either wait or add to the growing pile of database work. What's one possible solution to this challenge?

Select an answer:

Have the database developer train the rest of the team so there are fewer handoffs.

Have the software developers split their time between other teams so they're not as productive

Encourage the database developer to work overtime to catch up with their work.

Create a large batch of work so the database developer can focus on finishing

8 0
2 years ago
True or false. Every word has only one correct spelling and pronunciation.
iren2701 [21]
<span>Every word has only one correct spelling and pronunciation.
This is a false statement.
</span>
6 0
3 years ago
Other questions:
  • Business Risks are ​
    15·1 answer
  • Typically, a dvd has how many times more capacity than a cd?
    5·1 answer
  • In order to achieve a win-win solution, all parties involved should negotiate a solution. True or False ?
    13·2 answers
  • How would Microsoft Word inform you of the error in the sentence below? (Tip: The error is in bold.)
    7·1 answer
  • Smart art and shapes are useful tools because they allow you to
    6·1 answer
  • Working for the Internal Revenue Service is a career in public safety. A. True B. False
    14·1 answer
  • PLEASE HELP I mainly only need the answer for 4.
    5·1 answer
  • What do macOS and Windows use to prevent us from accidentally deleting files?
    15·1 answer
  • An electronic element that stores data by changing its resistance based on the current that has passed through it (similar to RR
    5·1 answer
  • Why is quantum computing potentially a better fit for weather forecasting than classical computers?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!