For the sorting Choice, do the following: Right after your header file and using namespace std; int sortingChoice; // Declare the functions void SelectionSort(item Type A[], int N); int Min(item Type A[], int i, int N); void InsertionSort(item Type A[], int N); void BubbleSort(item Type A[], int N); In the main: a) Declare the array dynamically (this has been discussed in the class) using pointer b) Allocate memory to N number of data c) Get user inputs (do not initialize the array) using cin statement to fill up the array for all N elements d) Get the value for sortingChoice by properly prompting the user e) Write a switch statement using sorting Choice as controlling parameter, and call SelectionSort for case 1, InsertionSort for case 2, BubbleSort for case 3, and default case display an error message saying that the choice is wrong. Outside the switch statement, display the sorted array with proper title. If you have forgotten how to use switch statement, use the following structure switch(sorting Choice) case 1: SelectionSort(A, N); { break; case 2: InsertionSort(A, N); break; and so on default: cout << "Not a correct choice" << endl; } Then display the sorted array.
For the sorting Choice, do the following: Right after your header file and using namespace std; int sortingChoice; // Declare the functions void SelectionSort(item Type A[], int N); int Min(item Type A[], int i, int N); void InsertionSort(item Type A[], int N); void BubbleSort(item Type A[], int N); In the main: a) Declare the array dynamically (this has been discussed in the class) using pointer b) Allocate memory to N number of data c) Get user inputs (do not initialize the array) using cin statement to fill up the array for all N elements d) Get the value for sortingChoice by properly prompting the user e) Write a switch statement using sorting Choice as controlling parameter, and call SelectionSort for case 1, InsertionSort for case 2, BubbleSort for case 3, and default case display an error message saying that the choice is wrong. Outside the switch statement, display the sorted array with proper title. If you have forgotten how to use switch statement, use the following structure switch(sorting Choice) case 1: SelectionSort(A, N); { break; case 2: InsertionSort(A, N); break; and so on default: cout << "Not a correct choice" << endl; } Then display the sorted array.
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
Related questions
Question
Expert Solution
Step 1
Algorithm:
1. Begin.
2. Declare sortingChoice, N, and A (an array).
3. Prompt the user to enter the number of elements and store it in N.
4. Prompt the user to enter the elements of the array and store it in A.
5. Prompt the user to enter the sorting choice.
6. Compare the sorting choice
6a. If sortingChoice is 1, call SelectionSort().
6b. If sortingChoice is 2, call InsertionSort().
6c. If sortingChoice is 3, call BubbleSort().
6d. Otherwise, display an error message.
7. After the sorting, display the sorted array.
8. Free the memory allocated for A.
9. End.
Step by step
Solved in 8 steps with 12 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education