# Big-O Cheat Sheet

## Definition

Big-O notation, represents an algorithm's worst-case complexity. It uses algebraic terms to describe the complexity of an algorithm, allowing you to measure its efficiency and performance. Below you can find a chart that illustrates Big-O complexity:

Simply put, `O(1)` stands for constant time complexity, which is the most efficient, while `O(n!)` stands for factorial time complexity, which is the least efficient. The `n` in the complexity represents the size of the input, so `O(n)` means that the algorithm's time complexity will grow linearly with the size of the input.

Apart from Big-O notation, there are other notations that are used to describe the complexity of an algorithm, such as `Î©` (Omega) and `Î˜` (Theta). `Î©` describes the best-case complexity of an algorithm, while `Î˜` describes the average-case complexity of an algorithm.

## Common Data Structure operations

Different data structures have different time complexities for the same operations. For example, a linked list has `O(1)` time complexity for `insert` and `delete` operations, while an array has `O(n)` time complexity for the same operations. Below you can find average and worst time complexities for data structures used commonly in web development.

## Array sorting algorithms

Similar to data structures, different array sorting algorithms have different time complexities. Below you can find the best, average and worst time complexities for the most common array sorting algorithms.

## More like this

• Collection · 10 snippets

### JavaScript Performance Optimization

Optimize your JavaScript with this collections of tips and tricks and take your website to the next level.

• JavaScript ·

### Asynchronous JavaScript Cheat Sheet

Learn everything you need to know about promises and asynchronous JavaScript with this handy cheatsheet.

• JavaScript ·

### JavaScript modules Cheat Sheet

Learn everything you need to know about JavaScript modules with this handy cheatsheet.

• JavaScript ·

### Group data using the K-means clustering algorithm in JavaScript

Implement the K-means clustering algorithm in JavaScript to group data into clusters.

Start typing a keyphrase to see matching snippets.