Question
//My program #include #include #include using namespace std; //function bubble sort to sort the array void bubbleSort(int a[]) { int i, j; int temp; for
//My program
#include
using namespace std;
//function bubble sort to sort the array void bubbleSort(int a[]) { int i, j; int temp;
for (i = 1; i a[j + 1]) { temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } }
//binary search fuction to search the element in the array void binarySearch(int arr[], int search) { int i, first, last, middle; first = 0; last = 1000 - 1; middle = (first + last) / 2;
while (first last) { cout
int main() {
int array[1000]; int search, n = 0; long timeElapsed;
//start time and end time stored here clock_t start, end; srand((unsigned) time(0));
for (int i = 0; i > search;
//count the time before searching start = clock(); binarySearch(array, search); //count the time after searching end = clock(); timeElapsed = end - start;
//print the time taken by searching cout It is a C++ assignment. The main goal of this program is time analysis by using bubble sort and binary search algorithms. Assignment requirements as following; 1. Make an array that store 1000 random integers between 1-1000 2. Let the user to input an int for search 3. Apply the clock); method to time the execution of the search and sort 4. Make bubble sort algorithm which sort the array before binary search algorithm is executed 5. Make and implement a binary search algorithm 6. Execute the program 4 times running modified bubble sort as the sorting algorithm 7. Count the time it takes to execute the sort in milliseconds or even nanoseconds 8. Please explain your results 9. Explain each line of your codes 10. Lastly, include Pseudocode of program Note: I already coded the above steps as you can see in following my program. Now I want someone do the following changes in my program; replace bubble sort and binary search with linear search Explain your results while you are using linear search instead of binary search and bubble sort? Explain your each line of your linear search Include Pseudocode of your linear search Execute the program through your computer's terminal 1. 2. 3. 4. 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started