C++ Help with Assignment//// Below is an external link for the files that would
ID: 3721926 • Letter: C
Question
C++ Help with Assignment////
Below is an external link for the files that would have taken too much space to put up on here.
https://www.dropbox.com/s/303yvceob6k27ol/Unit-7%20%281%29.zip?dl=0
Zip files contain 3 header files and 1 cpp file
Assignment This program should create two arrays, each with exactly the same values. You will then need to sort one of these arrays Next, use these arrays to create two search trees. All four data structures will have exactly the same values, but in different configurations. You will then search for several values in each of these data structures, and collect timing information about the length of the searches. Finally, you will write a brief report showing your findings. Your program should output something like this when you are finished Fri Feb 9 9:01:25 2018 Search of unordered array found 41 items in ??? clock ticks. Search of ordered array found 41 items in?? clock ticks. Search of tree from unordered array found 41 items in 238 clock ticks. Search of tree from ordered array found 41 items in??? clock ticks 1. Declare an array of integers. Use your first name as part of the variable name, like bills arr. For the size, use the last 5 digits of your student id. Fill the array with random integers. 2. Make a copy of this array, and sort the copy. You may sort it any way you like. 3. Use the first array to initialize an stree. Use the sorted array to initialize another stree. 4. Create a vector of integers. Use your last name as part of the variable name, like smiths_guesses. Add some random integers to this vector. The number of values you should add is the last 3 digits of your student id. 5. Use a sequential search to search for every item in your guess vector to see if it is in the unsorted array. Keep track of the number of items found. Keep track of the time used. Print your results. 6. Use a binary search to search for every item in your guess vector to see if it is in the sorted array. Keep track of the number of items found. Keep track of the time used. Print your results.Explanation / Answer
bool sameElements(int Arr1[], int Arr2[], int size) { bool found; found = false; if (size == 1) { if (Arr1[0] == Arr2[0]) return true; else return false; }//if else { //size != 1 int i; //index for loop for (i = size - 1; i >= 0 && !found ; i--) { if (Arr2[i] == Arr1[size-1]) { // check existence of element in Arr1 swapInArray(Arr2, i, (size - 1)); // swap elements found = true; }//if } if (found) sameElements(Arr1, Arr2, size - 1); // send to recursion with size-1 else return false; } } void swapInArray(int arr[], int i, int j) { int temp; temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.