BigβO Complexity Visualizer - Online Compare O(1) to O(n!)
Plot different BigβO complexities on a chart. See how O(log n) stays flat while O(2^n) explodes. Educational reference.
UD5 Toolkit
Watch Bubble, Quick & Merge Sort in action β step by step
| Algorithm | Best | Average | Worst | Space | Stable |
|---|---|---|---|---|---|
| Bubble Sort | O(n) | O(nΒ²) | O(nΒ²) | O(1) | Yes |
| Quick Sort | O(n log n) | O(n log n) | O(nΒ²) | O(log n) | No |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
A sorting algorithm rearranges elements of a list or array into a specific order β typically numerical ascending or descending. Sorting is fundamental in computer science, enabling efficient searching, data analysis, and optimized algorithms that rely on ordered data.
Bubble Sort repeatedly steps through the list, compares adjacent elements, and swaps them if they're in the wrong order. Larger elements "bubble up" to the end with each pass. It's intuitive but inefficient β O(nΒ²) in average and worst cases β making it impractical for large datasets.
Quick Sort picks a "pivot" element, partitions the array so that smaller elements are left of the pivot and larger ones are right, then recursively sorts the sub-arrays. It averages O(n log n) and is often the fastest in practice due to cache efficiency, though worst-case is O(nΒ²).
Merge Sort divides the array into halves, recursively sorts each half, then merges the sorted halves back together. It guarantees O(n log n) in all cases and is stable, but requires O(n) extra space, making it ideal when stability and predictability matter.
In practice, Quick Sort is usually fastest for general-purpose in-memory sorting due to low constant factors and cache locality. However, Merge Sort is more predictable and excels with linked lists or external data. For very small arrays, insertion sort (not shown here) can beat both.
A stable sorting algorithm preserves the relative order of equal elements. If two items have the same key, their original order is maintained after sorting. Merge Sort and Bubble Sort are stable; Quick Sort (typical implementations) is not. Stability matters when sorting by multiple criteria.
Use Bubble Sort only for educational purposes or tiny datasets (n < 20). For real applications, Quick Sort is the default choice for arrays in most programming languages' standard libraries. If stability or guaranteed O(n log n) is required, consider Merge Sort or Timsort.
An in-place sorting algorithm uses O(1) or O(log n) extra space beyond the input array. Bubble Sort is in-place (O(1)). Quick Sort is in-place (O(log n) for recursion stack). Merge Sort is not in-place β it requires O(n) auxiliary space for merging.
Plot different BigβO complexities on a chart. See how O(log n) stays flat while O(2^n) explodes. Educational reference.
Add, remove, push, pop items and watch the data structure change visually. Supports arrays, stacks, and queues. For CS students.
Paste HTML and see the order in which elements would receive focus via Tab key. Highlight issues. Local accessibility testing.
See the complete recursion tree for small Fibonacci or factorial calculations. Understand overlapping subproblems. Educational.
Sort lines of text alphabetically, numerically, or by length. Reverse order supported. Perfect for organizing lists and data sets with complete privacy.
Paste a CSS rule and sort its declarations alphabetically or by box model grouping. Clean up styles.
Paste your CSS and sort the properties of each rule alphabetically or by concentric groups. Keep your stylesheets consistent without a build step.
Enter a URL and see a visual map of the tab order. Detect broken tabindex values. Improve keyboard navigation.
Enter text and see each character's 8βbit binary laid out in a blackβandβwhite grid. Beautiful data art. Local.
Sort hundreds of lines alphabetically, reverse alphabetically, or by length. Deduplicate option. All local.
Type a simple sentence and see a rudimentary ReedβKellogg diagram. Educational.
Enter a decimal number and see a visual breakdown of bits, place values, and bitwise operations. Learn binary easily.
Drag dog breed names into the correct AKC group (herding, sporting, etc.). Learn breed categories.
Define multiple @layer blocks and see which styles win. Understand layer order and revertβlayer. Modern CSS architecture.
Take a list of items and reverse the line order. The first becomes last. Simple and quick.
Enter a number and see its Collatz sequence graphed. Watch the steps until it reaches 1. Mesmerizing math.
Enter a list of buzzwords or concepts and shuffle them into random pairs. Stimulate creative thinking. All local.
See how grid-auto-flow: row vs column changes item placement. Add and remove items to understand the algorithm. Visual.
Enter a regular expression and see a visual railroad diagram explaining the pattern. Learn and debug regex.
Understand how !important behaves inside @layer vs unlayered styles. Interactive example. Avoid common pitfalls.
Enter a URL and extract tabβindex order violations and focusable elements. Quick accessibility audit. Clientβside fetch.
Enter a simple regular expression and see its equivalent Deterministic Finite Automaton diagram. Learn how regex engines work.
Create categorized shopping lists (produce, dairy, meat, etc.). Add items, check them off, and print. Data stored in your browser. Never lose a list.
Paste plain text and turn it into a nested outline using indent levels or Markdown headings. Great for planning.
Create a weighed pros and cons list with a score. Help make tough decisions. Data saved locally.
Track personal expenses and categorize spending. Interactive charts show where your money goes. All financial data remains in your browser only.
Paste a Kanji and watch it drawn stroke by stroke with numbered sequence. Excellent for learners. Static data set.
Generate a checklist for traveling with only a carryβon. Mixβandβmatch outfits. Toiletries rules.
Select a heading font and get recommended body font pairings. Live preview with sample text. Copy the CSS import links.
Use browser compass and geolocation to show which planets and stars are overhead. Minimal, local only.