Top "Big-o" questions

The Big-O notation is used to represent asymptotic upper bounds.

Can hash tables really be O(1)?

It seems to be common knowledge that hash tables can achieve O(1), but that has never made sense to me. …

algorithm performance language-agnostic big-o hashtable
Complexity of factorial recursive algorithm

Today in class my teacher wrote on the blackboard this recursive factorial algorithm: int factorial(int n) { if (n == 1) return 1; …

complexity-theory big-o factorial
Difference between Big-Theta and Big O notation in simple language

While trying to understand the difference between Theta and O notation I came across the following statement : The Theta-notation asymptotically …

algorithm big-o big-theta
Why lookup in a Binary Search Tree is O(log(n))?

I can see how, when looking up a value in a BST we leave half the tree everytime we compare …

data-structures time-complexity big-o binary-search-tree
Time complexity for Shell sort?

First, here's my Shell sort code (using Java): public char[] shellSort(char[] chars) { int n = chars.length; int increment = n / 2; …

algorithm big-o time-complexity shellsort
Complexity of list.index(x) in Python

I'm referring to this: http://docs.python.org/tutorial/datastructures.html What would be the running time of list.index(…

python algorithm list big-o performance
What's the Big-O of a stack, queue, set, and deque?

What is the Big-O efficiency of a stack, queue, set, and deque as it pertains to insertion, search, indexing, space, …

stack set queue big-o deque
Computing set intersection in linear time?

Is there an algorithm that, given two sets, computes their intersection in linear time? I can run two for loops …

algorithm math data-structures big-o set-intersection
Finding Big O of the Harmonic Series

Prove that 1 + 1/2 + 1/3 + ... + 1/n is O(log n). Assume n = 2^k I put the series into the summation, but I have …

time-complexity big-o complexity-theory
Why is bubble sort O(n^2)?

for (int front = 1; front < intArray.length; front++) { for (int i = 0; i < intArray.length - front; i++) { if (intArray[…

algorithm sorting complexity-theory big-o bubble-sort