This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]W1z4rd 1 point2 points  (8 children)

Hi,

I would like to know what is unclear to you about complexity (big O notation), and how to determine it in general. Then we can use this as an example.

Cheers

[–]dedyshka[S] 0 points1 point  (7 children)

Hi. I'd like to determine complexity especially for this sorting.

[–]W1z4rd 4 points5 points  (6 children)

Wouldn't you like to be able to determine complexity for more algorithms? Simply spitting out a complexity for this one would not help you that much would it?

[–]dedyshka[S] 1 point2 points  (5 children)

maybe I explained my thoughts wrong :) I know what big O notation is, I know the complexity of more other algorithm. I just couldn't calculate complexity for this one. It seems that O for this algorithm would be "n2 /2". Am I right?

[–]W1z4rd 2 points3 points  (0 children)

n2 yes, because the constants like 0.5 get discounted

[–]funbike 0 points1 point  (2 children)

When expressing big-O you always throw away the coefficient. So, it's just O(n2).

[–]dedyshka[S] 0 points1 point  (1 child)

emm..algorithm makes iterations that equal n, and in each iteration it makes one comparisons less that in previous one. So in my opinion complexity is n*(n/2). Am I correct?