TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Unconscious Algorithms

14 点作者 droctothorpe超过 4 年前

2 条评论

scaramanga超过 4 年前
&gt; The time and space complexity are both O(n)<p>Actually the worst case time complexity is O(n * m). To see why, imagine searching for a big string of the form &quot;aaa...aaax&quot; in the much bigger string of the form &quot;aaa...aaax&quot;.<p>The analysis case for average time is more tricky. You could intuitively think that it, too, should include an &quot;m&quot; term, right? But if strings are uniformly random then the probability of finding your way in to the n&#x27;th character of the needle from any given start position decreases geometrically (1, 1&#x2F;256, 1&#x2F;65536, ...). Since the sum of any such geometric series is a constant[0], we end up with O(n) * O(1) so it&#x27;s just O(n).<p>[0]. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Geometric_series#Sum" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Geometric_series#Sum</a>
评论 #25527680 未加载
coolgeek超过 4 年前
I don&#x27;t know if Pinker attributes this (or if he independently came up with the observation), but the quote relates to Moravec&#x27;s Paradox<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Moravec%27s_paradox" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Moravec%27s_paradox</a>