What are the main sorting algorithms and their complexities?
Computer Science
ScanSolve AI Answer
Bubble Sort: O(n²) — compare adjacent pairs, swap if wrong order. Simple but slow. Selection Sort: O(n²) — find minimum, place at front. Insertion Sort: O(n²) — insert each element into sorted portion. Good for small/nearly sorted data. Merge Sort: O(n log n) — divide in half, sort each, merge. Stable, consistent. Quick Sort: O(n log n) average, O(n²) worst — pick pivot, partition. Fastest in practice. Heap Sort: O(n log n) — uses binary heap. For most cases, use your language's built-in sort (usually Timsort, a hybrid).
Was this helpful?
Still stuck on this one?
Ask a follow-up, and the answer starts from this question.
Got a different question?Ask your own question
More Computer Science Questions
QTeach me sorting algorithms well like a beginner so that I can be able to identify the type in a…QI.a) Is the time complexity of an algorithm based on the best-case or the worst-case scenario of the…QAnalyze the time complexity of the following functions using Big-O Notation, and explain the concept…QExplain the concepts of binary and linear search, Big-O notation, computational complexity, and…QAlgorithms or problems described as hard or intractable refer to their time complexity, specifically…
Browse by topic:Algorithms