Question: ( 1 6 pts ) You are given a random array consisting of integers ( including positive, negative, and 0 ) , and each element

(16 pts) You are given a random array consisting of integers (including positive, negative, and 0), and each element may be repeated.
Note: for all the questions below, please use the iostream library only.
a)(4 pts) Write a function bubbleSort to implement Bubble Sort to sort the array in descending order.
Function signature:
void bubbleSort(int nums[], int n)
Example:
Input: nums =[5,1,9,6,5,1,2],n=7
Expected realization: nums =[9,6,5,5,2,1,1]
b)(6 pts) Write a function quickSort to implement Quick Sort to sort the array in descending order.
Function signature:
void quickSort (int nums[], int n)
Example: see above.
c)(3 pts) Write a function dedup Licate to remove the repeated integers from your sorted array and return the length of the updated array. Do not use extra memory space.
Function signature:
int deduplicate(int nums[], int n)
Example:
Input: nums =[9,6,5,5,2,1,1],n=7
Expected realization: nums =[9,6,5,2,1]
Output: 5
d)(3 pts) What are the time and space complexity of each function that you realized above? Explain why.
 (16 pts) You are given a random array consisting of integers

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!