w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
comparison sort algorithms requires Ω(nlgn) comparisons in the worst case

To oversimplify slightly*, when we talk about lower bounds for algorithmic problems, we're interested in how the best algorithm does in the worst case. The best comparison-based sorting algorithms (e.g., mergesort) use roughly n log n comparisons in the worst case, so the lower bound for sorting is quoted as Omega(n log n). Algorithms that are not the best, e.g., bubble sort, may do materially worse than the best algorithm in the worst case. In the best case, they may do better than the best algorithm. Neither of these facts is inconsistent with the lower bound for sorting.

*There may not be one best algorithm.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.