Top "Big-o" questions

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

Why hashmap lookup is O(1) i.e. constant time?

If we look from Java perspective then we can say that hashmap lookup takes constant time. But what about internal …

data-structures hash hashmap hashtable big-o
algorithms: how do divide-and-conquer and time complexity O(nlogn) relate?

In my Algorithms and Data Structures class a first divide-and-conquer algorithm namely merge sort was introduced. While implementing an algorithm …

performance algorithm big-o divide-and-conquer
Linear time v.s. Quadratic time

Often, some of the answers mention that a given solution is linear, or that another one is quadratic. How to …

python big-o complexity-theory time-complexity
Average Runtime of Quickselect

Wikipedia states that the average runtime of quickselect algorithm (Link) is O(n). However, I could not clearly understand how …

algorithm big-o
Why is insertion sort Θ(n^2) in the average case?

Insertion sort has a runtime that is Ω(n) (when the input is sorted) and O(n2) (when the input is …

algorithm sorting big-o insertion-sort
Big O of JavaScript arrays

Arrays in JavaScript are very easy to modify by adding and removing items. It somewhat masks the fact that most …

javascript arrays algorithm big-o time-complexity
What is the Big-O of String.contains() in Java?

I'm working on a project, and need to optimize the running time. Is String.contains() runtime the same as TreeSet.…

java string big-o contains
What is pseudopolynomial time? How does it differ from polynomial time?

What is pseudopolynomial time? How does it differ from polynomial time? Some algorithms that run in pseudopolynomial time have runtimes …

algorithm big-o time-complexity
Time Complexity of two for loops

So I know that the time complexity of: for(i;i<x;i++){ for(y;y<x;y++){ //…

algorithm complexity-theory big-o
How is LinkedList's add(int, E) of O(1) complexity?

From the linked-list tag wiki excerpt: A linked list is a data structure in which the elements contain references to …

java linked-list big-o time-complexity