1

I've calculated the running time of an algorithm I'm interested in to be

$$O(0.24\cdot K\cdot 2^{w})\,,$$

where $K$ and $w$ are both variables. ($K$ is the number of elements in some set, and $w$ is the log of the largest element, so both are variables.)

What kind of growth does this function have? I'll say it is exponential, however I don't know what the 0.24 implies.

Raphael
  • 73,212
  • 30
  • 182
  • 400
Jesus Salas
  • 519
  • 1
  • 4
  • 17

2 Answers2

2

If $K$ is constant and $w$ is variable then $0.24\times K\times 2^w$ and the function is exponential in $w$, therefore it is $O(2^w)$.

If $K$ is variable and $w$ is constant then $0.24\times K\times 2^w$ is $O(K)$ - linear in $K$.

If both $K$ and $w$ are variables then $0.24\times K\times 2^w$ is $O(K2^w)$.

If both $K$ and $w$ are constant then $0.24\times K\times 2^w$ is $O(1)$.

The constant $0.24$ is ignored since it becomes irrelevant when we compare the rate of growth of a function. For more details please see Big-O notation.

We also use $O^*(f(n))$ notation, in particular in analysis of parametrized algorithms, which means that the algorithm runs in $O(f(n)p(k))$ for some polynomial $p(k)$. So you could also write it is $O^*(2^w)$ in case $w$ is variable.

fade2black
  • 9,905
  • 2
  • 26
  • 36
2

The function $f(K,w) = K\cdot 2^w$ has polynomial (in fact, linear) dependence on $K$ and exponential dependence on $w$.

You're interested in the function $g(K,w) = 0.24\cdot f(K,w)$ but the constant multiplier doesn't change anything. Linear growth in $K$ means that, if $K$ doubles, then $f(K,w)$ doubles, too. But doubling $K$ also doubles $g(K,w)$. Exponential growth (with base $2$) means that adding $1$ to $w$ doubles $f(K,w)$, and the same applies to $g$.

David Richerby
  • 82,470
  • 26
  • 145
  • 239