LANGUAGE IS C++
Assignment 6B: Forwards and Backwards. Up to this point, we have sorted array values from smallest to largest. However, there are times when we need to do the reverse and sort from largest to smallest. We will implement a way to do this using Insertion Sort and Selection Sort.
Take in an initial array size value from the user (C++ students: Check the Appendix for more information on how to do this) and a value for the highest possible value in the sequence. Fill the array with random values between 0 and that highest value. Then provide the user with the
following options:
Change the array’s elements with new random values
◦ Use the numbers entered by the user initially for this; do not prompt the user for new
numbers
Sort from smallest to largest
◦ Use Insertion Sort to sort the array so that the smallest value is at index 0, and the
largest value is at the end of the array.
Sort from largest to smallest
◦ Use Selection Sort to sort the array so that the largest value is at index 0, and the
smallest value is at the end of the array.
Quit to end the program
After an option is picked (except for Quit), print the array out and provide the choices to the user
once again. The sample output shows the format of your program’s output – however, the values
will be different since the numbers are generated randomly.
I included sample outputs in the pictures...
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Write a C++ program : Question:Ask user to give you a list of the numbers and then Sort them, by calling two functions: Asc(Sort in Ascending order), and Desc(Sort in Descending order): Do the above question by using array. First ask user how many numbers are there in the list and then get the numbers and sort them.arrow_forwardIn C++.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education