100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Computer Science Reference

Big-O Complexity Reference

Big-O describes how an algorithm's cost grows as the input grows, ignoring constants — O(1) is unaffected by size, O(log n) halves the problem each step, O(n) scales in step with it, and O(n²) becomes unusable quickly. This reference gives the time and space complexity of the data structures and algorithms interviews test.

82 entries7 categoriesFree, no sign-up

Browse by Category

All Big-O Complexity (82)

Notations (10)

What each growth class means in practice.

Constant time

Average

O(1)

Notes

Cost does not change as the input grows. Array indexing and hash lookups. At one million items, still about one step.

Worst

Logarithmic time

Average

O(log n)

Notes

Discards a fixed fraction of the input each step, so doubling the input adds one step. One million items takes about 20 steps.

Worst

Square-root time

Average

O(√n)

Notes

Appears in jump search and in block-decomposition techniques. One million items takes about 1,000 steps.

Worst

Linear time

Average

O(n)

Notes

Touches each element a constant number of times. One million items takes about one million steps — the ceiling for anything that must read all its input.

Worst

Linearithmic time

Average

O(n log n)

Notes

The proven lower bound for comparison sorting. One million items takes about 20 million steps, which is still comfortably fast.

Worst

Quadratic time

Average

O(n²)

Notes

Every element against every other — nested loops. One million items is 10¹² steps, which will not finish. Fine at n in the hundreds.

Worst

Cubic time

Average

O(n³)

Notes

Three nested loops, as in naive matrix multiplication and Floyd-Warshall. Practical only for a few hundred elements.

Worst

Exponential time

Average

O(2ⁿ)

Notes

Doubles with each added element — subset enumeration and naive recursive Fibonacci. Unusable past roughly n = 30 without memoisation.

Worst

Factorial time

Average

O(n!)

Notes

Every ordering of the input, as in brute-force travelling salesman. Unusable past about n = 12.

Worst

Amortised constant

Average

O(1)*

Notes

Occasional expensive operations averaged over many cheap ones — a dynamic array doubling its buffer. Any single call may be O(n); the average is O(1).

Worst

Arrays & Lists (14)

Contiguous and linked sequences.

Array · access by index

Average

O(1)

Notes

Address arithmetic on a contiguous block — no traversal involved.

Worst

O(1)

Array · search unsorted

Average

O(n)

Notes

No structure to exploit, so every element may have to be examined.

Worst

O(n)

Array · insert at index

Average

O(n)

Notes

Every later element shifts one place to make room.

Worst

O(n)

Array · delete at index

Average

O(n)

Notes

Every later element shifts back to close the gap.

Worst

O(n)

Dynamic array · append

Average

O(1)*

Notes

Amortised: writing is constant until the buffer is full, then everything is copied to a larger one. Python list, Java ArrayList, C++ vector.

Worst

O(n)

Dynamic array · pop from end

Average

O(1)

Notes

Nothing shifts, so removing the last element is genuinely constant.

Worst

O(1)

Singly linked list · access

Average

O(n)

Notes

No indexing — reaching position k means following k pointers from the head.

Worst

O(n)

Singly linked list · insert at head

Average

O(1)

Notes

Point the new node at the old head and move the head pointer. No shifting anywhere.

Worst

O(1)

Singly linked list · delete at head

Average

O(1)

Notes

Advance the head pointer past the removed node.

Worst

O(1)

Singly linked list · delete a known node

Average

O(n)

Notes

The previous node must be found to relink it, and a singly linked list cannot walk backwards.

Worst

O(n)

Doubly linked list · delete a known node

Average

O(1)

Notes

Each node knows its predecessor, so relinking needs no search. This is what makes an LRU cache O(1).

Worst

O(1)

Stack · push / pop / peek

Average

O(1)

Notes

All work happens at one end, whether backed by an array or a linked list.

Worst

O(1)

Queue · enqueue / dequeue

Average

O(1)

Notes

Constant at both ends when implemented as a linked list or a circular buffer. A naive array queue is O(n) to dequeue.

Worst

O(1)

Deque · push / pop either end

Average

O(1)

Notes

Amortised constant at both ends. Python collections.deque, Java ArrayDeque.

Worst

O(1)

Hash Tables & Sets (7)

Key-based lookup structures.

Hash table · lookup

Average

O(1)

Notes

Hash the key, go straight to the bucket. Degrades to a linear scan when every key collides.

Worst

O(n)

Hash table · insert

Average

O(1)*

Notes

Amortised: constant until the load factor is exceeded and the table is rehashed, which is O(n).

Worst

O(n)

Hash table · delete

Average

O(1)

Notes

Same bucket lookup as a search, then unlink. Open-addressing tables need tombstones to stay correct.

Worst

O(n)

Java HashMap · lookup

Average

O(1)

Notes

Since Java 8 a bucket with many collisions becomes a red-black tree, so the worst case is O(log n) rather than O(n).

Worst

O(log n)

Hash set · add / contains

Average

O(1)

Notes

A hash table storing only keys. The reason deduplication is usually written with a set.

Worst

O(n)

Bloom filter · add / query

Average

O(k)

Notes

k hash functions, independent of the number of items stored. Says "definitely not present" or "probably present", and cannot delete.

Worst

O(k)

LRU cache · get / put

Average

O(1)

Notes

A hash map for lookup plus a doubly linked list for recency. Both halves are needed to hit O(1).

Worst

O(1)

Trees & Heaps (15)

Ordered hierarchical structures.

Binary search tree · search

Average

O(log n)

Notes

Halves the range at each node while the tree is balanced. Inserting sorted data produces a linked list, hence the worst case.

Worst

O(n)

Binary search tree · insert / delete

Average

O(log n)

Notes

Follows the same path as a search, then relinks. Degenerates alongside search when the tree is unbalanced.

Worst

O(n)

AVL tree · search / insert / delete

Average

O(log n)

Notes

Rebalances by rotation after every write, keeping height tightly bounded. More rotations than red-black, faster lookups.

Worst

O(log n)

Red-black tree · search / insert / delete

Average

O(log n)

Notes

Looser balance than AVL, so fewer rotations on write. Backs Java TreeMap and C++ std::map.

Worst

O(log n)

B-tree · search / insert / delete

Average

O(log n)

Notes

High branching factor keeps the tree shallow, so each level is one disk or page read. The structure behind database indexes.

Worst

O(log n)

Binary heap · find min

Average

O(1)

Notes

The minimum is always the root, so peeking costs nothing.

Worst

O(1)

Binary heap · insert

Average

O(log n)

Notes

Place at the end and sift upwards through at most the height of the tree.

Worst

O(log n)

Binary heap · extract min

Average

O(log n)

Notes

Move the last element to the root and sift down.

Worst

O(log n)

Binary heap · build from array

Average

O(n)

Notes

Heapify bottom-up is linear, not O(n log n) — most nodes are near the leaves and sift down barely at all.

Worst

O(n)

Fibonacci heap · decrease key

Average

O(1)*

Notes

Amortised constant, which is what makes the theoretical bound on Dijkstra better. Constant factors are poor enough that binary heaps usually win in practice.

Worst

O(log n)

Trie · insert / search

Average

O(m)

Notes

Depends on key length m, not on how many keys are stored — so lookup does not slow down as the dictionary grows.

Worst

O(m)

Trie · prefix search

Average

O(m + k)

Notes

Walk the prefix, then collect the k results beneath it. The reason autocomplete uses a trie.

Worst

O(m + k)

Segment tree · query / update

Average

O(log n)

Notes

Range queries and point updates on an array. Building it is O(n).

Worst

O(log n)

Fenwick tree · query / update

Average

O(log n)

Notes

Prefix sums with far less memory and code than a segment tree, at the cost of flexibility.

Worst

O(log n)

Skip list · search / insert / delete

Average

O(log n)

Notes

Randomised layers give balanced-tree performance with much simpler code. Used in Redis sorted sets.

Worst

O(n)

Sorting Algorithms (12)

Comparison and non-comparison sorts.

Quicksort

Average

O(n log n)

Notes

Fastest in practice thanks to cache behaviour and in-place partitioning. O(n²) when pivots are consistently poor; O(log n) stack space. Not stable.

Worst

O(n²)

Introsort

Average

O(n log n)

Notes

Quicksort that switches to heapsort once recursion runs too deep, removing the O(n²) worst case. This is what C++ std::sort actually is.

Worst

O(n log n)

Mergesort

Average

O(n log n)

Notes

Guaranteed bound and stable, at the cost of O(n) extra space. The right choice for linked lists and external sorting.

Worst

O(n log n)

Heapsort

Average

O(n log n)

Notes

Guaranteed bound in O(1) space, but poor locality makes it slower than quicksort in practice. Not stable.

Worst

O(n log n)

Timsort

Average

O(n log n)

Notes

Detects runs already in order, so nearly sorted input approaches O(n). Stable, O(n) space. Used by Python sorted() and Java Arrays.sort on objects.

Worst

O(n log n)

Insertion sort

Average

O(n²)

Notes

O(n) on nearly sorted input and very low overhead, so real sorts fall back to it for small partitions. Stable, in place.

Worst

O(n²)

Bubble sort

Average

O(n²)

Notes

O(n) on already sorted input with an early exit. Taught for the idea, never used in practice.

Worst

O(n²)

Selection sort

Average

O(n²)

Notes

Always O(n²) regardless of input, but makes only O(n) writes — occasionally relevant when writes are expensive.

Worst

O(n²)

Shell sort

Average

O(n log² n)

Notes

Insertion sort over decreasing gaps. The exact bound depends on the gap sequence chosen.

Worst

O(n²)

Counting sort

Average

O(n + k)

Notes

Beats O(n log n) by not comparing at all, but needs O(k) space for the value range. Only viable when k is small.

Worst

O(n + k)

Radix sort

Average

O(d·(n + k))

Notes

Counting sort applied one digit at a time, d digits deep. Linear when key width is fixed, as for 32-bit integers.

Worst

O(d·(n + k))

Bucket sort

Average

O(n + k)

Notes

Assumes input is spread evenly across buckets. Collapses to O(n²) when everything lands in one bucket.

Worst

O(n²)

Graph Algorithms (12)

Traversal, shortest path and spanning trees.

Breadth-first search

Average

O(V + E)

Notes

Visits every vertex and edge once. Finds the shortest path in an unweighted graph; O(V) queue space.

Worst

O(V + E)

Depth-first search

Average

O(V + E)

Notes

Same bound as BFS. Used for cycle detection, topological order and connected components; O(V) stack depth.

Worst

O(V + E)

Dijkstra (binary heap)

Average

O((V + E) log V)

Notes

Shortest paths from one source with non-negative weights. The usual implementation.

Worst

O((V + E) log V)

Dijkstra (Fibonacci heap)

Average

O(E + V log V)

Notes

The best known bound, thanks to O(1) amortised decrease-key. Rarely worth the constant factors in practice.

Worst

O(E + V log V)

Bellman-Ford

Average

O(V·E)

Notes

Slower than Dijkstra but handles negative edge weights and detects negative cycles.

Worst

O(V·E)

Floyd-Warshall

Average

O(V³)

Notes

Shortest paths between every pair of vertices, in O(V²) space. Practical up to a few hundred vertices.

Worst

O(V³)

A* search

Average

O(E)

Notes

Dijkstra guided by a heuristic. With an admissible heuristic it is optimal; with a poor one it degrades towards exponential.

Worst

O(bᵈ)

Kruskal (MST)

Average

O(E log E)

Notes

Dominated by sorting the edges. Uses union-find to reject edges that would form a cycle.

Worst

O(E log E)

Prim (MST, binary heap)

Average

O(E log V)

Notes

Grows one tree outwards. Preferred over Kruskal on dense graphs.

Worst

O(E log V)

Topological sort

Average

O(V + E)

Notes

Orders a DAG so every edge points forwards. Kahn's algorithm also detects cycles.

Worst

O(V + E)

Union-Find (path compression + rank)

Average

O(α(n))

Notes

The inverse Ackermann function is below 5 for any input that fits in a computer, so this is constant in every practical sense.

Worst

O(α(n))

Tarjan (strongly connected components)

Average

O(V + E)

Notes

Finds all SCCs in a single depth-first pass.

Worst

O(V + E)

Frequently Asked Questions

What does O(1) mean?

O(1) means constant time — the operation takes about the same time no matter how large the input is. Reading an array element by index or looking up a key in a hash table are O(1): the cost does not grow when the collection does.

Why is O(log n) so much better than O(n)?

A logarithmic algorithm discards half the remaining input at each step, so doubling the input adds only one more step. Searching a sorted array of a billion items takes about 30 comparisons with binary search, against a billion with a linear scan.

What is the fastest sorting algorithm?

No comparison sort can beat O(n log n) on average, and quicksort, mergesort and heapsort all hit it. Quicksort is usually fastest in practice because of cache behaviour, mergesort is stable and predictable, and counting or radix sort can beat O(n log n) only because they do not compare elements.

Does Big-O measure actual running time?

No. It describes how cost grows with input size and deliberately drops constants and lower-order terms, so an O(n) algorithm can be slower than an O(n²) one on small inputs. It tells you which algorithm wins as the data gets large, not which is faster today.

Related Reading

Frequently Asked Questions

21 categories · pick one to explore

What is SkillVeris?
SkillVeris is a completely free tech-upskilling platform offering 37 live courses across AI/ML, programming, web development, DevOps, cloud, security and databases. It combines structured courses of 24–40 lessons, a 24/7 AI Mentor, and a unique Learn Through Hobbies method that explains technical concepts through cricket, music, gaming, cooking and more. It is powered by Sri Hayavadhana.
Is SkillVeris really a free learning platform?
Yes, SkillVeris is genuinely free. Every course, assessment, certificate, study note, cheat sheet and the AI Mentor are available at no cost. There are no hidden paywalls, trial periods or premium tiers locking away lessons. The platform was built to make quality tech education accessible to learners in India and worldwide without financial barriers.
Who is SkillVeris for?
SkillVeris is for anyone learning technology skills: complete beginners starting to code, students preparing for placements, working professionals switching into AI, DevOps or cloud roles, and hobbyists exploring new tools. Courses span beginner to advanced levels, and the Learn Through Hobbies method makes complex topics approachable even if you have no technical background at all.
What makes SkillVeris different from other online learning platforms?
SkillVeris stands out with its Learn Through Hobbies method, which teaches every concept through analogies from cricket, music, gaming, cooking and eight more domains you can switch instantly. Add a free 24/7 AI Mentor, structured courses of 24–40 lessons with certificates, Code Lab for in-browser practice, and a live jobs portal, all completely free of charge.
What can I learn on SkillVeris?
You can learn AI and machine learning, Python, programming fundamentals, web development, DevOps, cloud computing, security and databases through 37 live courses. Beyond courses, SkillVeris offers study notes, cheat sheets, a glossary of roughly 2,000+ terms, 500+ blog articles, interview questions with readiness scoring, and Code Lab supporting six programming languages.
Does SkillVeris offer personalized learning?
Yes, personalization is central to SkillVeris. You choose the analogy domain that matches your interests, cricket, gaming, music, cooking and more, and lessons instantly adapt their explanations. The AI Mentor answers your questions at Quick, Detailed or Deep-dive depth, and learning paths guide you toward specific careers like AI Engineer or DevOps Engineer.
Do I need any prior experience to start learning on SkillVeris?
No prior experience is needed. Many SkillVeris courses are designed for absolute beginners, starting from fundamentals and building up gradually across 35 structured lessons. The Learn Through Hobbies analogies explain technical ideas using everyday interests, so newcomers grasp concepts faster. Intermediate and advanced courses are also available when you are ready to progress.
How do I get started with SkillVeris?
Simply visit skillveris.com, create a free account, and pick a course from the Topics page or follow a learning path like AI Engineer or Full Stack Java Developer. Choose your favourite analogy domain, work through the lessons, pass the module assessments and final exam, and earn your certificate, all without paying anything.
Is SkillVeris available in India?
Yes, SkillVeris is fully available in India and is built with Indian learners strongly in mind. All 37 courses, certificates and tools are free, and the jobs portal aggregates live roles across India alongside the UK, USA, Germany and remote positions, with salary and experience filters to help you find relevant opportunities.
Can I use SkillVeris on my mobile phone?
Yes, SkillVeris works in any modern mobile browser, so you can read lessons, switch analogy domains, ask the AI Mentor questions and take assessments from your phone. The platform is designed to load fast on mobile connections, making it practical to learn during commutes or short breaks without needing a laptop.
What is the Learn Through Hobbies method on SkillVeris?
Learn Through Hobbies is SkillVeris's signature teaching approach: every key concept is explained through analogies drawn from twelve domains including cricket, music, gaming, cooking, fitness, travel and finance. You pick the domain you love and can switch instantly, so abstract topics like machine learning pipelines feel familiar rather than intimidating.
Does SkillVeris have an AI tutor?
Yes, SkillVeris includes a built-in AI Mentor available 24/7. You can ask it any question about your lessons or technology in general and choose the depth of the answer: Quick for a fast summary, Detailed for a fuller explanation, or Deep-dive for a thorough walkthrough. It is free for every learner.
Does SkillVeris help with job hunting?
Yes, SkillVeris has a jobs portal aggregating live roles across India, the UK, USA, Germany and remote positions, with salary and experience filters. Combined with interview questions featuring readiness scoring, career-focused learning paths and free certificates you can share, the platform supports your job search from skill-building through to applications.
What learning paths does SkillVeris offer?
SkillVeris offers career-oriented learning paths such as AI Engineer, DevOps Engineer and Full Stack Java Developer, among others. Each path sequences relevant courses in a logical order so you build skills progressively toward a specific role, rather than guessing which course to take next. All path courses are free and include certificates.
How much time do I need to complete a SkillVeris course?
It depends on your pace. Structured courses contain 24–40 lessons (most have 35) plus module assessments and a final exam, and each lesson typically takes around half an hour of focused reading and practice. Many learners finish a course in a few weeks studying part-time, while dedicated full-time learners can move considerably faster.
Can I practice coding on SkillVeris?
Yes, SkillVeris includes Code Lab, an in-browser coding environment supporting six programming languages across 15 practice categories. You can write and run code directly in your browser without installing anything, which makes it easy to reinforce what you learn in lessons immediately. Code Lab is free, like everything else on the platform.
Does SkillVeris have free study materials besides courses?
Yes, alongside courses SkillVeris offers free study notes, cheat sheets for quick revision, a glossary of roughly 2,000+ technical terms, more than 500 blog articles, and interview questions with readiness scoring. These resources complement the courses and are handy for exam preparation, interviews and quick refreshers, all at no cost.
Who powers SkillVeris?
SkillVeris is powered by Sri Hayavadhana. The platform's mission is to make high-quality technology education free and genuinely engaging, combining structured courses, an always-available AI Mentor and the Learn Through Hobbies analogy method so learners in India and around the world can upskill without cost being a barrier.
Is SkillVeris suitable for working professionals switching careers?
Yes, career switchers can follow structured learning paths like AI Engineer or DevOps Engineer, study flexibly around work using mobile-friendly lessons, and validate their progress through assessments and certificates. The jobs portal with salary and experience filters, plus interview questions with readiness scoring, helps professionals move into new tech roles confidently.
How is SkillVeris free, is there a catch?
There is no catch. SkillVeris does not charge for courses, certificates, the AI Mentor, Code Lab or any learning resource, and there are no trial expirations or locked premium content. The platform exists to make tech education accessible, particularly for learners in India and other regions where paid platforms are often out of reach.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse