Asymptotic complexity is an approximation of the edge case performance of an algorithm used to determine best and worst case scenarios.
Questions tagged [asymptotic-complexity]
796 questions
3
votes
2 answers
Algorithms : Master Theorem
Master theorem can be used to solve recurrence relations like
T(n)= aT(n/b)+f(n).
So, if f(n)=O(n) or if f(n)=cn are both the values same?
can I use master theorem for f(n)=cn also?

pratik watwani
- 117
- 1
- 2
- 11
3
votes
1 answer
Does g(n) ∈ O(f(n)) imply f(n) ∈ Ω(g(n))?
I am just trying to understand how Big O and Big Omega work. I know that Big O means no better than, and Big Omega means no worse than running times. So if I have a function g(n) such that g(n) = O(f(n)) then can I say that f(n) = Ω(g(n))?

Romaldowoho
- 405
- 1
- 7
- 20
3
votes
1 answer
Big-O of code fragment with nested loops
We've received a fragment of code to find its big-O:
for(int i = 1;i ≤ n;i = 2 ∗ i)
for(int j = 1;j ≤ i;j = 2 ∗ j)
for(int k = 0; k ≤ j; k++)
//do something elementary
The first line should be O(log(n)) but it gets…

E. Rose
- 53
- 4
3
votes
1 answer
Between O(nlog*n) and O(n)?
Is there any real complexity between O(n logstar(n) ) and O(n)?
I know that O(n sqrt(logstar(n))) and other similar functions are between these two but I mean something original which is not made of logstar(n).

A. Mashreghi
- 1,729
- 2
- 20
- 33
3
votes
3 answers
What is the asymptotic complexity of this particular (bad) algorithm for computing the square root of a number?
Stumbled across a (terrible) algorithm for computing the square root of a number. Got into a small argument about the time complexity. I assert that the time complexity is O(n^2) because for n input, it will be multiplied n times. My friend asserts…

hrazzer
- 79
- 8
3
votes
1 answer
Trying to figure out the run time of my function
I have this python code for finding the longest substring. I'm trying to figure out the asymptotic run time of it and I've arrived at an answer but I'm not sure if it's correct. Here is the code:
def longest_substring(s, t):
best = ' '
for…

donut juice
- 257
- 6
- 19
3
votes
1 answer
More efficient algorithm to count attacks in N-queens?
I'm working on a DFS based solution to the N-queens problem.
I store the board state as an int[N] array representing the vertical placements of queens in each column (eg. placement of the queens diagonally down a 6x6 board would be state = { 0, 1,…

Brendan Hill
- 3,406
- 4
- 32
- 61
3
votes
2 answers
What's the complexity of getJSONObject and getJSONArray methods?
I'm using org.json library as JSON-client for my Java application and I would like to know the complexity of some methods from this lib.
I'm retrieving thousands of JSON objects inside a JSON array inside another JSON objects (and so on) from a…

Paladini
- 4,522
- 15
- 53
- 96
3
votes
3 answers
Determine running time of the code
I have written following dp code today, it worked fine as it got some points in for submission (here is the problem). However I am not able to determine the running time of my code. I feel like its O(n^2 * log D) but I can't prove it.
class…

codeomnitrix
- 4,179
- 19
- 66
- 102
3
votes
3 answers
Asymptotic complexity for typical expressions
The increasing order of following functions shown in the picture below in terms of asymptotic complexity is:
(A) f1(n); f4(n); f2(n); f3(n)
(B) f1(n); f2(n); f3(n); f4(n);
(C) f2(n); f1(n); f4(n); f3(n)
(D) f1(n); f2(n); f4(n); f3(n)
a)time…

coder101
- 840
- 2
- 11
- 29
3
votes
2 answers
a HashSet.contains() returning an Object
Suppose i'm working a type A in Collections.
class A {
ThisType thisField;
ThatType thatField;
String otherField;
}
Only thisField and thatField are relevant to identify the instances of A-- so its equals() and along with it…

Roam
- 4,831
- 9
- 43
- 72
3
votes
1 answer
Can an operation that takes O(1) amortized time have worst-case O(n^2) time?
If an operation has an amortized time of O(1), can it ever, worst-case, take O(N^2) time?

bst-for-life
- 41
- 5
3
votes
3 answers
Algorithm domination
Studying for a test and getting this question:
Comparing two algorithms with asymptotic complexities O(n) and O(n + log(n)),
which one of the following is true?
A) O(n + log(n)) dominates O(n)
B) O(n) dominates O(n + log(n))
C) Neither algorithm…

Deekor
- 9,144
- 16
- 69
- 121
3
votes
2 answers
Asymptotic Analysis questions
I found a couple questions on geeksforgeeks.org that i can't seem to understand(#1 and #3). I was hoping someone could clarify the answers for me:
clarify whether true/valid or false
1.Time Complexity of QuickSort is Θ(n^2)
I answered true but it…

user2644819
- 1,787
- 7
- 28
- 41
3
votes
3 answers
c++ finding same record in vector
Ihave a vector that contains monthyear
Jan2013
Jan2013
Jan2013
Jan2014
Jan2014
Jan2014
Jan2014
Feb2014
Feb2014
Basically what I want to do is to search through the vector, for every same record, group them
together like
e.g
total count for…

user2947249
- 187
- 2
- 3
- 11