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.

Counting Inversions via Rank Queries

11 pointsby johndcookover 5 years ago

1 comment

brudgersover 5 years ago
<i>counting the number of inversions of a sequence in O(n \lg n) time</i><p>Counting inversions is equivalent to sorting. That&#x27;s why it&#x27;s 0(n log n). Any sorting algorithm can become an inversion counting algorithm by incrementing a counter instead of rearranging the input values. Inversions are the first topic in <i>The Art of Computer Programming</i> Chapter 5. Very much worth reading if you dig this stuff.
评论 #21952890 未加载