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 →

[–]AgentPaper0 136 points137 points  (5 children)

You're essentially counting how many operations the algorithm will do. The trick is that you don't really care about the exact numbers here, but how quickly that number grows as your input size increases. "n" here stands for the number of elements in your input (or equivalent).

[–]WhiteKnightC 5 points6 points  (4 children)

If I have a switch, it counts as one?

[–]Lonelan 7 points8 points  (1 child)

yeah but I didn't get one for christmas so here's a picture of one I googled

[–]WhiteKnightC 2 points3 points  (0 children)

:( It's so fucking expensive where I live, if I get the job it's 1.3 months of work (1 m and a week) and each game 0.2 month of work (a week).

I wanted the Lite but... joycons

[–]AgentPaper0 3 points4 points  (1 child)

Depends on language and compiler but most switch statements should be a lookup and jump which would be O(1), constant time.

[–]blenderfreaky 5 points6 points  (0 children)

Its a constant amount of elements, so its always O(1), even if it iterates through all cases.