Question: Program in C++ Data Structure Task 3: Update your program from Assignment 6 and 3. Create an array that holds 100000 random floats between 1-1000.

Program in C++ Data Structure

Task 3:

Update your program from Assignment 6 and 3.

Create an array that holds 100000 random floats between 1-1000.

Depending on your computer and compiler the above example may not work. Attempt to execute from the command line is Visual Studio / IDE doesn't work. Reduce the number of floats to 10,000 if your computer cannot handle the execution.

Allow the user to enter an floats to search.

Create and implement modified bubble sort algorithm which will sort the array before the Binary Search algorithm is executed.

Create and implement Insertion sort algorithm which will sort the array before the Binary Search algorithm is executed.

Create and implement a Binary Search Algorithm .

If the number exists in the array and output the position.

If the search key does not exist in the Array simple output value not found.

Use the clock(); method to time the execution of the search and sort

Execute the program 4 times. Twice running the modified bubble sort as the sorting algorithm and twice running the Insertion Sort as the sorting algorithm

Describe your results

Here is my previous code:

#include #include #include #include

using namespace std;

class Average{ private: float numarray[1000]; public:

void randomarray(){ srand (time(NULL)); for(int i=0;i<1000;i++){ float r = (rand() / (float)RAND_MAX * 99) + 1; numarray[i] = floor(r); } }

void showaray(){ for(int i=0;i<1000;i++){ cout<

float summing(){ float sum = 0; for(int i=0;i<1000;i++){ sum = sum + numarray[i]; } return sum; }

float averagearay(){ float s = summing(); return s/1000; }

void BinarySearch(float input){ int smallest = 0; for(int i=0;i<1000;i++){ smallest = i; for(int j=i+1;j<1000;j++){ if(numarray[j] < numarray[smallest]){ smallest = j; } } float temp= numarray[i]; numarray[i] = numarray[smallest]; numarray[smallest] = temp; }

int l = 0; int r = 999; int found = 0; int m; while (l <= r){ m = l + (r-l)/2; if (numarray[m] == input){ found = 1; break; }

if (numarray[m] < input) l = m + 1; else r = m - 1; } if(found == 1){ cout<<" Number:"<

}

};

main(){ Average obj; obj.randomarray(); obj.showaray(); cout<

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!