Question: 2. (80pts) Sorting algorithm: Write a program that prompts users to input 10 integers into a vector. Write a function for each of the following

2. (80pts) Sorting algorithm: Write a program that prompts users to input 10 integers into a vector. Write a function for each of the following two sorting algorithms that takes a vector as its argument. (a) Bubble sort: Use bubble sort to sort the vector in increasing order. Print out the sorted vector. Note: You must specifically comment in your code the swap operation in the bubble sort (basically, indicate that which lines of your code implement the swap). Otherwise you will get point deduction for not commenting your code. (b) Selection sort: Use selection sort to sort the vector in decreasing order. Print out the sorted vector. Note: You must specifically comment in your code which variable records the current minimal or maximal (depending on your implementation). Otherwise you will get point deduction for not commenting your code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!