Arrays & Sorting Overview

An Array is a fundamental linear data structure that stores collection of elements sequentially in contiguous memory locations. Because memory addresses are calculated directly via index math, accessing any item takes instant constant time $O(1)$.

Key Array Characteristics:

Explore Sorting Algorithms

Click on any card below to open its dedicated deep-dive theory sheet with step-by-step code and execution details:

Bubble Sort

Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.

Simple • $O(n^2)$

Quick Sort

Divide-and-conquer algorithm that selects a 'pivot' element and partitions the array around it.

Fast • $O(n \log n)$

Insertion Sort

Builds the sorted array one item at a time. Extremely efficient for small or nearly-sorted datasets.

Adaptive • $O(n^2)$

Merge Sort

Recursively splits array in halves, sorts each half, and merges them back together predictably.

Stable • $O(n \log n)$

Sorting Algorithms Comparison

Here is a summary of theoretical performance, space complexity, and properties across different algorithms:

Algorithm Best Time Average Time Worst Time Space Stable? In-Place?
Bubble Sort $O(n)$ $O(n^2)$ $O(n^2)$ $O(1)$ Yes Yes
Insertion Sort $O(n)$ $O(n^2)$ $O(n^2)$ $O(1)$ Yes Yes
Quick Sort $O(n \log n)$ $O(n \log n)$ $O(n^2)$ $O(\log n)$ No Yes
Merge Sort $O(n \log n)$ $O(n \log n)$ $O(n \log n)$ $O(n)$ Yes No