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.

TreeMap - Search Time Complexity

What is the time complexity of a get() and put() in a TreeMap? Is the implementation same as a Red-Black …

java search insert time-complexity treemap
What is the difference between O, Ω, and Θ?

I am learning algorithm analysis. I am having trouble understanding the difference between O, Ω, and Θ. The way they're defined is …

algorithm big-o time-complexity
What's the worst case complexity for KMP when the goal is to find all occurrences of a certain string?

I would also like to know which algorithm has the worst case complexity of all for finding all occurrences of …

string algorithm time-complexity knuth-morris-pratt
Pop multiple values from Redis data structure atomically?

Is there a Redis data structure, which would allow atomic operation of popping (get+remove) multiple elements, which it contains? …

data-structures redis time-complexity atomicity
What sort does Java Collections.sort(nodes) use?

I think it is MergeSort, which is O(n log n). However, the following output disagrees: -1,0000000099000391,0000000099000427 1,0000000099000427,0000000099000346 5,0000000099000391,0000000099000346 1,0000000099000427,0000000099000345 5,0000000099000391,0000000099000345 1,0000000099000346,0000000099000345 I am sorting …

java collections sorting time-complexity mergesort
Complexity of the recursion: T(n) = T(n-1) + T(n-2) + C

I want to understand how to arrive at the complexity of the below recurrence relation. T(n) = T(n-1) + T(…

algorithm complexity-theory time-complexity recurrence asymptotic-complexity
O(klogk) time algorithm to find kth smallest element from a binary heap

We have an n-node binary heap which contains n distinct items (smallest item at the root). For a k<=…

algorithm search data-structures heap time-complexity
If strings are immutable in .NET, then why does Substring take O(n) time?

Given that strings are immutable in .NET, I'm wondering why they have been designed such that string.Substring() takes O(…

c# .net string substring time-complexity
Worst case in Max-Heapify - How do you get 2n/3?

In CLRS, third Edition, on page 155, it is given that in MAX-HEAPIFY, The children’s subtrees each have size at …

algorithm tree heap time-complexity
Trie complexity and searching

What is the complexity of creating a trie of a list of words and what is complexity of searching other …

algorithm data-structures time-complexity hashtable trie