Question: You are given the following algorithm: Algorithm whatIsThis ( A [ 0 . . . n - 1 ] ) mergesort ( A ) i

You are given the following algorithm:
Algorithm whatIsThis(A[0...n-1])
mergesort(A)
i 0
while i < n do
while i < n-1 and A[i]= A[i+1] do
i i +1
B[i] A[i]
i i +1
return B
a. What is the purpose of this algorithm?
b. There is one logical error in this algorithm. Find and correct it.
c. What is the complexity of this algorithm? Explain your reasoning.

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 Programming Questions!