✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
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