Question
intro to c++ sorting and searching with vectors 1. Write a C++ program that will be similar to version 1 (you MUST use vectors for
intro to c++
sorting and searching with vectors
1. Write a C++ program that will be similar to version 1 (you MUST use vectors for this assignment and make a copy of your version 1 program [make only the necessary changes to have it work with vectors instead of arrays]). 2. Prompt the user for the number of elements they want in the vector. 2. Using the rand function to generate random numbers between 1 and another number specified by the user (prompt the user for this value) and fill the vector with random integers between 1 and the user specified maximum value.
2.The program must output the vector of random integers with a function named displayList.
3. Have the program sort the vector of random integers from largest to smallest ( current discussion on sorting has sorting algorithms sort from smallest to largest, how do we do the opposite? ). Use either bubble sort ( if you really feel up for the out-side-the-box-thinking challenge, try heap sort - this is normally taught in data structures - 1 point extra credit for using merge sort or heap sort [ pseudocode located in the How To Folder ] ).
4. The program must output the sorted vector of random integers again with a function named displayList. 5. Prompt the user to enter a value to search for by using Binary Search ( this value may or may not be in the list of random values generated ). 6. Output whether or not Binary Search found the search value and output the index of where the value was located, if it was found, otherwise output that it was not found. Make sure to use the input validation techniques we have discussed and used (kitty cat proof input)
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