【问题标题】:Need assistance with Proof for Nested Loops and Exponentials在证明嵌套循环和指数方面需要帮助
【发布时间】:2017-03-19 13:56:24
【问题描述】:

是否可以将任何嵌套循环的增长表示为指数?这是我和几个同学的讨论。我试图用指数定律证明:

If n = the size of the outer loop
If k = the size of the inner loop

Then, if we use n as our base and the value of n is n^1:
Then, if n^x = k, the total = n^(1+x) for any n and k.

这应该适用于我认为的任何基础。此外,只要您使用相同的底座,从技术上讲,外部循环可以提高到任何功率。

编辑:澄清代码示例:

for (int i =1; i <= n; i++){

  for (int j = 1; j <= k; j++){

   /// whatever

  }

}

Let us say that:
n = 10
k = 5

We would expect that the total would be 10 * 5 = 50
50 maximum loops

I am saying that:
10 = 10^1 -> outer loop
5 = 10^.69897 -> inner loop
10^1.69897 = 50

这应该适用于任何基地。

【问题讨论】:

  • 你对循环的growthsize的定义是什么? total 代表什么?
  • 通过增长,我们谈论的是相对于内部循环大小的变化率。总数表示最里面的操作将运行的最大次数
  • 所以 size 是指迭代次数nk 是常量吗?如果不是,它们是通过哪种算法改变的?
  • 好吧,你总是可以写成 10 * 5 = 10^1 * 10^log10(5) = 10^(1 + log10(5)) ...如果这个表示对你有用,来吧,使用它。
  • 我真的想知道这是否成立,或者它是否恰好在这里工作。我还是新手。

标签: algorithm math theory


【解决方案1】:

我不确定这与循环有什么关系,但通常假设您有任意两个数字,nk,并且您想在基数 n 处表示 n*k

n 将是 10 在基数 n k 将是 10^(log k)log 表示以 10 为底的对数)

所以n*k = 10 * 10^(log k) = 10^(log k + 1) 所以,是的,数学成立。但我不确定你为什么选择这样看待它。

【讨论】:

  • 在一次讨论中,我把自己逼到了角落,不得不证明这一点。
  • 另外,多一种做事的方式永远不会有坏处。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-23
  • 1970-01-01
  • 2012-12-26
  • 2021-05-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多