logo

Crowdly

Browser

Додати до Chrome

What is the space complexity (BigO) of this algorithm? Note: the algorithm is de...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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 n

In 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

0%
0%
0%
0%
0%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на cyberlearn.hes-so.ch?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome