Question: // In the algorithm, assume that there are two arrays named B[0..n1] // and C[0..n1] in addition to the input array A[0..n-1]. Algorithm DoSomething (A[0..n1])

// In the algorithm, assume that there are two arrays named B[0..n1]

// and C[0..n1] in addition to the input array A[0..n-1].

Algorithm DoSomething (A[0..n1])

i <- 0

while (i < n) do

B[i] <- 0

i <- i + 1

i <- 0

while (i < n1) do

j <- i + 1

while (j < n) do

if A[i] > A[j]

B[j] <- B[j] + 1

else

B[i] <- B[i] + 1

j <- j + 1

i <- i + 1

i <- 0

while (i < n) do

C[B[i]] = A[i];

i <- i + 1

Present the basic operation of the algorithm. When you describe the basic operation, you should also present the line number of the basic operation clearly.

Present the time complexity of the algorithm using the O notation.

Assume that the input array A has the values 7, 2, 8, 3, 5. Present the final results of the arrays B[ ] and C[ ]

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!