开发者

Brainstorm: To compute x/y in log(n) time, [closed]

开发者_JS百科 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

How will you compute x/y in O(log(n)) time.

n=x/y, x & y are integers

You can't use the / operator.

One implementation is to add y q times till the result is less than x i.e.

y * q < x


What about 10**(log(x) - log(y))

Big O() notation only applies to how a problem scales with different number of inputs.
The question doesn't make sense unless you mean 'n' is the number of digits in x and y

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜