Search code examples
performancedata-structuresqueuespacespace-complexity

Difference between "linear in" and "proportional to"?


A programming assignment was explicitly changed from

use space proportional to the number of items currently in the queue

to

use space linear in the number of items currently in the queue

what is the difference?


Solution

  • As already mentioned by Jonathan Dursi in the comment, there is a subtle difference between linear in and proportional to.

    Linear means a given parameter varies with the change in the other parameter,where there may be constant term difference too.

    Ex :- y = 5x +3 , here y varies linearly with x and is 3 more than 5 times of x.

    So, dependent on 5 times of x(power=1),not on other powers of x is the commonness between them. But, the presence of +3 makes it linear and not proportional.

    To make y proportional to x, y must be equal to y = kx, where k is some real number. There shouldn't be any constant term in the form of addition/subtraction/exponentiation. Constants are permitted as a form of product/divisor.