4 ms·
You cannot talk about complexity without letting n-> infinity. Both algorithms are O(1), since n is bounded.
by ChrisLomont 4y ago
You cannot talk about complexity without letting n-> infinity. Both algorithms are O(1), since n is bounded.
- Sebb767 4y agoTrue, but I wanted to go with a simple example to show my point.
- waynesonfire 4y agohow is n bounded in the 2nd algorithm?
- xigoi 4y agoIf you assume that it's unbounded, then either the algorithms aren't solving the same problem or the first one is wrong, so it doesn't make sense to compare them.