r/badcode • • Dec 20 '16

c Is point inside rectangle? Now O(n^2).

Post image
333 Upvotes

72 comments sorted by

View all comments

Show parent comments

2

u/cwolf79 Dec 22 '16

I think we can both agree that if you hold m, p and n constant then q would be O(n). That is because all the variables are in the same complexity class i.e. they differ by a constant.

That is why the argument doesn't hold for your other examples. E is not in the same complexity class as V. And n is not in the same complexity class as 1.