Answer the question
In order to leave comments, you need to log in
What will be the complexity of this algorithm?
The code inside the loop calls the sort function with O(n log n) complexity:
for item in N:
sort(item)
...
Answer the question
In order to leave comments, you need to log in
Depends on the size of the item. If they are there each O(N) size, then your guess is correct: O(n^2 log n).
If all items do not exceed N in total, then the answer is O(N log N). Because if their sizes are a_i, then you have the sum ai log ai. log(ai) can be limited from above to log(N) and put out of brackets and then replace the sum in brackets with N.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question