Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need the code in C++. Generate a list of 100 random integers and implement the

ID: 3634416 • Letter: I

Question

I need the code in C++.

Generate a list of 100 random integers and implement the Binary Search algorithm using the STL vector class. Next, code a Linear Search function also using the STL vector class. Linear Search sequentially goes through each element of the vector one by one until it finds the desired element. Note that Binary Search requires the integers to be sorted, while Linear Search does not. Time the execution of your program for list sizes of 102, 103, 104, and 105. Make sure to only sort your integers when performing Binary Search and to attribute the extra time associated with sorting the list. Output the times for various list sizes. Use the selection sort algorithm in your class notes and compare the timing of sorting some list of random numbers to sorting a list of numbers using the vector STL sort function. Print out the timing for various list sizes. As you know, Bubblesort is the sort that dropped out of college and lives in his parents basement eating ramen noodles. However, there is a sort that makes Bubblesort look like the most successful sorting brother by comparison, termed Bogosort. Given a list of say 10 random numbers, check if they are in order. If they are not in order shuffle the items around randomly Check again if they are in order. Do this until the shuffling actually produces the correct ordering. (Note: Please do not ever use this algorithm for anything ever with the exception of this lab.)

Explanation / Answer

Binary Search Algorithm int binarySearch(int sortedArray[], int first, int last, int key) { // function: // Searches sortedArray[first]..sortedArray[last] for key. // returns: index of the matching element if it finds key, // otherwise -(index where it could be inserted)-1. // parameters: // sortedArray in array of sorted (ascending) values. // first, last in lower and upper subscript bounds // key in value to search for. // returns: // index of key, or -insertion_position -1 if key is not // in the array. This value can easily be // transformed into the position to insert it. while (first sortedArray[mid]) first = mid + 1; // repeat search in top half. else if (key