Top "Time-complexity" questions

The time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the size of the input to the problem.

O(n log n) vs O(n) -- practical differences in time complexity

n log n > n -- but this is like a pseudo-linear relationship. If n=1 billion, log n ~ 30; So n …

algorithm big-o time-complexity
Time complexity for java ArrayList

Is ArrayList an array or a list in java? what is the time complexity for the get operation, is it …

java arraylist time-complexity
Understanding Time complexity calculation for Dijkstra Algorithm

As per my understanding, I have calculated time complexity of Dijkstra Algorithm as big-O notation using adjacency list given below. …

algorithm graph big-o time-complexity dijkstra
What would cause an algorithm to have O(log log n) complexity?

This earlier question addresses some of the factors that might cause an algorithm to have O(log n) complexity. What …

algorithm big-o time-complexity complexity-theory logarithm
Merge Sort Time and Space Complexity

Let's take this implementation of Merge Sort as an example void mergesort(Item a[], int l, int r) { if (r &…

algorithm time-complexity space-complexity
How efficient/fast is Python's 'in'? (Time Complexity wise)

In Python, what is the efficiency of the in keyword, such as in: a = [1, 2, 3] if 4 in a: ...

python performance time-complexity operator-keyword
Breadth First Search time complexity analysis

The time complexity to go over each adjacent edge of a vertex is, say, O(N), where N is number …

algorithm graph time-complexity breadth-first-search
What would cause an algorithm to have O(log n) complexity?

My knowledge of big-O is limited, and when log terms show up in the equation it throws me off even …

algorithm big-o time-complexity logarithm
Maximum single-sell profit

Suppose we are given an array of n integers representing stock prices on a single day. We want to find …

arrays algorithm big-o time-complexity
Find the majority element in array

The majority element is the element that occurs more than half of the size of the array. How to find …

arrays algorithm time-complexity