Using Ruby as the math language, the OP's formula is
f = -> x { 2 * x ** 2 + x }
(1) Assuming that one step of algorithm takes 1 unit of time, the answer is 50
, because the constant term c
is
c = 24 - f.( 2 ) #=> 10
# and
c + f.( 4 ) #=> 50
Under this assumption, the answer is 50.
(2) If, however, we allow one step of the algorithm to take e
time units instead of 1 time unit, then the constant c
will be:
24 - e * 10
and the running time for n == 4
will be
24 + e * 26 # gives 50 for e == 1
(3) With an additional assumption, that the constant time is zero (that is, the given formula is exact), we have
24 - e * 10 == 0
And the answers by Candide, bcorso and Milky Dinescu apply.
Although the OP question does not literally state that 1 step == 1 time unit, I still feel that this was the author's intention, also based on the typical, easy-to-check textbook result of 50
.