How the optimal value of jumping block size is found in jump search?

Viewed 601

The value of the function ((n/m) + m-1) will be minimum when m = √n. Therefore, the best step size is m = √n. Here, n is size of array and m is block size to be jumped.

I understood that n/m is the jumps that we make for the worst case, m-1 is the times that is taken for linear search once we find the interval (arr[km] < x < arr[(k+1)m]).

But i don't understand how m=√n is found. I'm trying as below.

(n/m)+m-1=0;
(n/m)+m=1;
n+m^2=m;
n=m-m^2.

But how does this become m = m=√n

1 Answers
Related