A problem on moderately fast algorithms

For a function f ( n ) = n × lg ( n ) {f(n)}=n\times \lg\left(n\right) and time t = 1 0 3 \text{t}=10^{3} μ s \mu\text{s} , calculate the largest size of the problem n N \text{n} \in \mathbb{N} that can be solved in t \text{t} , assuming that for the algorithm to solve the problem it takes f ( n ) {f(n)} microseconds.

Details and assumptions :

1 1 ) Do it without WA \color{#3D99F6}{\text{without WA}}

2 2 ) Inspired from CLRS \color{#DBA97F}{\text{CLRS}}


The answer is 140.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

As already suggested, you were supposed to solve without WA.Here is one way,

n × l g ( n ) n\times lg\left(n\right) = 1000 1000 {solve for the equality to determine the largest n n and then take its floor value}

n n = 2 1000 n 2^{\dfrac{1000}{n}}

1000 1000 = 1000 n × 2 1000 n \dfrac{1000}{n} \times 2^{\dfrac{1000}{n}}

Let 1000 n \dfrac{1000}{n} = z z ................ ( ) \left(*\right)

Let f ( z ) f\left(z\right) = z × 2 z 1000 z \times 2^{z} -1000 , f ( z ) f'\left(z\right) = 2 z ( z l n ( 2 ) + 1 ) 2^{z}\left(zln(2) +1\right) and we are required to find roots of f ( z ) f\left(z\right)

Using Newton’s method \color{#20A900}{\text{Newton's method}} ,

z n + 1 z_{n+1} = z n f ( z n ) f ( z n ) z_{n} - \dfrac{f\left(z_{n}\right)}{f'\left(z_{n}\right)}

We know that 7 × 2 7 < 1000 < 8 × 2 8 7\times 2^{7} < 1000 < 8\times 2^{8}

\therefore we can guess the initial root as ~ 7.25 {i.e. z 0 = 7.25 z_{0}= 7.25 }and proceed as per Newton's method to obtain the approx. root z = 7.131561875 z = 7.131561875 .

n = 1000 7.131561875 n = \dfrac{1000}{7.131561875} ......................from ( ) \left(*\right)

n = 140 \boxed{ \lfloor n \rfloor= 140}

That's cool

ehhshs ebshshns - 8 months, 1 week ago

1 pending report

Vote up reports you agree with

×

Problem Loading...

Note Loading...

Set Loading...