Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions

Question

What is unsigned and signed numbers?

Answered: 1 week ago