logoalt Hacker News

another_twisttoday at 9:51 AM0 repliesview on HN

When the array is almost sorted. Bubble sort complexity is linear + inversions so if the inversions are low (the more sorted the array the lower the number of inversions), bubble sort is close to a linear pass.