Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

O-notation, O(∞) = O(1)?

Tags:

big-o

infinity

So a quick thought; Could one argue that O(∞) is actually O(1)?

  • I mean it isn't depend on input size?
  • So in some way its, constant, even though it infinity.

Or is the only 'correct' way to express it O(∞)?

like image 896
Poul Walker Avatar asked Apr 11 '11 20:04

Poul Walker


2 Answers

Infinity is not a number, or at least not a real number, so the expression is malformed. The correct way to express this is to simply state that a program doesn't terminate. Note: program, not algorithm, as an algorithm is guaranteed to terminate.

(If you wanted, you might be able to define big-O notation on transfinite numbers. I'm not sure if that would be of any use, though.)

like image 187
Fred Foo Avatar answered Jan 02 '23 14:01

Fred Foo


Your argument is not quite correct.

Big O notation disregards constant multiples; there's no difference between O(1) and O(42), or between O(log(n)) and O(3π log(n)) .

Standard convention is to not use any constant multiples.

However, O(∞) would mean an “algorithm” that never terminates, as opposed to O(1) which will terminate at some point.

like image 20
SLaks Avatar answered Jan 02 '23 14:01

SLaks