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.

Why is processing a sorted array faster than an unsorted array?

20 pointsby gphilipabout 10 years ago

3 comments

vmarsyabout 10 years ago
This is one of the classic posts here:<p><a href="https:&#x2F;&#x2F;hn.algolia.com&#x2F;?query=Why%20is%20processing%20a%20sorted%20array%20faster%20than%20an%20unsorted%20array%3F&amp;sort=byPopularity&amp;prefix&amp;page=0&amp;dateRange=all&amp;type=story" rel="nofollow">https:&#x2F;&#x2F;hn.algolia.com&#x2F;?query=Why%20is%20processing%20a%20so...</a><p>Very good comments in some of the submissions
etepabout 10 years ago
For completeness, a) make the array very big (much much bigger than the LLC) b) split the work amongst cores (make it parallel with your favorite methodology)
qnaalabout 10 years ago
<p><pre><code> int t = (data[c] - 128) &gt;&gt; 31; sum += ~t &amp; data[c]; </code></pre> &gt; They&#x27;ve gone to plaid