✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
What is the space complexity (BigO) of this algorithm?
Note: the algorithm is described in pseudo-code. The input array arr is an array of size nIn your calculation, do NOT consider the space used by the input array.
countDuplicates(arr) duplicates <- 0 sortedArr <- sort(arr) // here we sort the array for i from 1 to arr.length - 1 if sortedArr[i] = sortedArr[i-1] duplicates <- duplicates + 1 return duplicates
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!