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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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...

**Sample Output:**

**How large should the array be?** 10  
**What should be the highest number in the sequence?** 6  

5, 2, 2, 2, 3, 0, 1, 6, 2, 1,

**[Options]**  
1) Reset the array  
2) Sort (Smallest to Largest)  
3) Sort (Largest to Smallest)  
4) Quit  
**Choice?** 2  

**Using Insertion Sort:**  
0, 1, 1, 2, 2, 2, 2, 3, 5, 6,

**[Options]**  
1) Reset the array  
2) Sort (Smallest to Largest)  
3) Sort (Largest to Smallest)  
4) Quit  
**Choice?** 3  

**Using Selection Sort:**  
6, 5, 3, 2, 2, 2, 2, 1, 1, 0,
Transcribed Image Text:**Sample Output:** **How large should the array be?** 10 **What should be the highest number in the sequence?** 6 5, 2, 2, 2, 3, 0, 1, 6, 2, 1, **[Options]** 1) Reset the array 2) Sort (Smallest to Largest) 3) Sort (Largest to Smallest) 4) Quit **Choice?** 2 **Using Insertion Sort:** 0, 1, 1, 2, 2, 2, 2, 3, 5, 6, **[Options]** 1) Reset the array 2) Sort (Smallest to Largest) 3) Sort (Largest to Smallest) 4) Quit **Choice?** 3 **Using Selection Sort:** 6, 5, 3, 2, 2, 2, 2, 1, 1, 0,
[Options]
1) Reset the array
2) Sort (Smallest to Largest)
3) Sort (Largest to Smallest)
4) Quit
Choice? 1

Resetting the array:
1, 2, 6, 6, 4, 2, 4, 0, 0, 1,

[Options]
1) Reset the array
2) Sort (Smallest to Largest)
3) Sort (Largest to Smallest)
4) Quit
Choice? 4

Closing out...
Transcribed Image Text:[Options] 1) Reset the array 2) Sort (Smallest to Largest) 3) Sort (Largest to Smallest) 4) Quit Choice? 1 Resetting the array: 1, 2, 6, 6, 4, 2, 4, 0, 0, 1, [Options] 1) Reset the array 2) Sort (Smallest to Largest) 3) Sort (Largest to Smallest) 4) Quit Choice? 4 Closing out...
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education