Question: #include using namespace std; int linearSearch(int [], int,int); void selectionSort(int[],int); int main(){ int max=10; int ar[10]; cout cout for(int i=0;i cin>>ar[i]; } cout int searchNumber;

 #include using namespace std; int linearSearch(int [], int,int); void selectionSort(int[],int); int

#include

using namespace std;

int linearSearch(int [], int,int);

void selectionSort(int[],int);

int main(){

int max=10;

int ar[10];

cout

cout

for(int i=0;i

cin>>ar[i];

}

cout

int searchNumber;

cout

cout

cin>>searchNumber;

int result = linearSearch(ar,max,searchNumber);

if(result>=0){

cout

}

else{

cout

}

selectionSort(ar,max);

cout

cout

for (int i=0; i

cout

return 0; }

int linearSearch(int array[], int size,int numb){

for(int i=0; i

{

if(numb==array[i])

{

return i;

}

}

return -1; }

void selectionSort(int ar[],int size)

{

int min;

for(int i=0;i

{

min = i;

for(int j = i+1 ;j

if(ar[j]

{

min=j; }

}

swap (ar[i], ar[min]);

}

}

Develop algorithms to perform binary search. Extend your previous lab, and implement your algorithm in a separate function. Add a counter to your linear search function for the number of iterations required for the search. Additionally, add a similar counter to your binary search function Furthermore, change your array to handle 10,000 elements. Prompt the user for 10,000 values and then prompt the user for a query. Perform linear search. Sort the numbers, but remove the code to display the numbers in sorted order. Perform binary search. Not the difference between the number of iterations for linear search and binary search

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!