简体   繁体   English

算法:T(N) =2^N

[英]Algorithm: T(N) =2^N

Suppose the number of operations required by a particular algorithm is exactly T(n) = 2^n and our 1.6 Ghz computer performs exactly 1.6 billion operations per second.假设特定算法所需的操作次数正好是 T(n) = 2^n,我们的 1.6 Ghz 计算机每秒执行 16 亿次操作。 What is the largest problem, in terms of n, that can be solved in under a second?就 n 而言,可以在一秒钟内解决的最大问题是什么? In under a day?不到一天?

I tired 2^1.6 for a second and 2^(1.6*60*24), but I think I misunderstood the problem.我一秒钟累了 2^1.6 和 2^(1.6*60*24),但我想我误解了这个问题。

What we know:我们所知道的:

  • For being under 1 sec you need to perform less than 1.6*10^9 operations低于 1 秒,您需要执行少于 1.6*10^9 的操作
  • The number of operations needed is T(n)=2^n with n the size of the problem所需的操作次数为 T(n)=2^n,其中 n 为问题的大小

We are looking for the maximum n (the maximum size of the problem under 1 sec).我们正在寻找最大 n(1 秒内问题的最大大小)。 So we can write:所以我们可以写:

2^n <= 1.6*10^9 
n <= ln(1.6*10^9) / ln(2)
n <= 30

So in one sec you can compute a problem of size 30所以在一秒钟内你可以计算出一个大小为 30 的问题

Now 1 day is 24 * 60 * 60 seconds so:现在 1 天是 24 * 60 * 60 秒,所以:

2^n <= 86400 * 1.6*10^9 
n <= ln(86400 * 1.6*10^9)/ln(2)
n <= 46

So in one day you can compute a problem of size 46所以有一天你可以计算出一个大小为 46 的问题

Imagine the time needed for a problem of size 64...想象一下大小为 64 的问题所需的时间......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM