TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Unconscious Algorithms

14 pointsby droctothorpeover 4 years ago

2 comments

scaramangaover 4 years ago
&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 未加载
coolgeekover 4 years ago
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>