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
Why we need each section of prologprogram?
evablogger [386]

Answer:

Prolog program are used in the artificial intelligence and the web development in a systematic manner process. As, it is also sometimes known as declarative language which basically consist of some facts and list. Prolog program are divided into the sections that are:

  • Domain sections
  • Clauses sections
  • Predicates sections
  • Goal sections

We need each section of the prolog program because all the sections introduced the systematic program and performed there particular functions so by using all these processing steps an efficient function are formed.

6 0
3 years ago
En que parte del mall del rio venden tarjetas de google play en cuenca​
JulijaS [17]

chxgfk hcyskvuct auhchovuzq vuvscisv

6 0
3 years ago
PLEASE HELP!! Which of the following computing devices would best address the needs for a CYBER SECURITY ANALYST?
Tomtit [17]

Answer:high end laptop.

Explanation:

5 0
4 years ago
6. How might you go about securing an internship or job on LinkedIn?
Greeley [361]
Seems nice I mean yeah its be fine
4 0
4 years ago
Read 2 more answers
A ______ oversees the planning and implementation of sophisticated security measures to block unauthorized access but at the sam
meriva
A-database administrator
8 0
3 years ago
Other questions:
  • With a(n) ____, you can enter a value either by typing the value or by selecting it from a list.
    14·1 answer
  • What does a code of conduct include.
    10·2 answers
  • If I put a short clip from a copyrighted video to Facebook and make it only viewable to friends, is that illegal?
    12·1 answer
  • You have an old photograph that you want to incorporate in a brochure for your antique business. To convert the photo into digit
    9·2 answers
  • Which one of the following words is NOT an action verb?
    10·2 answers
  • On the Design tab, which group allows you to select a different data set for a chart?
    7·2 answers
  • _____ is the measure of a system’s ability to expand, change, or downsize easily to meet the changing needs of a business enterp
    11·1 answer
  • What alternative to leased lines is used by VPNs? As an alternative to leased lines, VPNs use ______ connections.
    11·1 answer
  • What are the trinity of the computer system
    15·1 answer
  • Identify the technique to free up the CPU by allowing device controllers to independently transfer data between the device and m
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!