Linked Questions
234 questions linked to/from Big O, how do you calculate/approximate it?
97
votes
4answers
7k views
What is the time complexity of my function? [duplicate]
Started studying about complexity, I'm struggling with this one:
void what(int n) {
int i;
for (i = 1; i <= n; i++) {
int x = n;
while (x > 0)
x -= i;
}
}...
9
votes
2answers
68k views
What is time complexity and how to find it? [duplicate]
I've read through so many resources and still am stuck with understanding what time complexity is. Resources I read were based on various formulas, I understood that O(n) is used to express time ...
3
votes
5answers
863 views
Compute the complexity of the following Algorithm? [duplicate]
Compute the complexity of the following Algorithm?
I have the following code snippet:
i = 1;
while (i < n + 1) {
j = 1;
while (j < n + 1) {
j = j * 2;
}
i = i + 1;
}
...
0
votes
0answers
23k views
How to calculate Big O notation from piece of code [duplicate]
Possible Duplicate:
Big O, how do you calculate/approximate it?
I have a piece of code, like this:
// A
for (i = 0; i < 2*n; i += 2) {
for (j=n; j > i; j--) {
foo();
}
}
//...
4
votes
2answers
3k views
Order of magnitude using Big-O notation [duplicate]
This is likely ground that has been covered but I have yet to find an explanation that I am able to understand. It is likely that I will soon feel embarrassed.
For instance, I am trying to find the ...
1
vote
3answers
3k views
Big-O for-loop runtime analysis [duplicate]
int n = 500;
for(int i = 0; i < n; i++)
for(int j = 0; j < i; j++)
sum++;
My guess is this is simply a O(N^2), but the j < i is giving me doubts.
int n = 500;
...
-2
votes
1answer
3k views
What is the time complexity of these dependent nested loops? [duplicate]
How to calculate time and space complexity for these algorithms?
I referred many sites but its confusing me. please any one explain me.
1.
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)//this for ...
1
vote
3answers
2k views
Finding/Calculating complexity of a method [duplicate]
Possible Duplicate:
Big O, how do you calculate/approximate it?
Plain English explanation of Big O
I just saw this question: Find nearest number in unordered array. In answers peoples are ...
0
votes
1answer
1k views
What is the Complexity of Find() Function [duplicate]
I have two versions of find function, both of which search an integer value in an array and return its position if exists. Function find1() will search up to N elements in worst case on the other hand ...
4
votes
3answers
327 views
O notation of a Loop [duplicate]
for(int i = 0; i < n; i++) {
for(int j = 0; j < i; j++) {
O(1);
}
}
here the func is n * (n+1) / 2 but what if the outerloop condition is i < log(n)? I have problems with loops ...
-1
votes
1answer
800 views
Order of growth according to Big-O Notation [duplicate]
Hello Stack Users, I am having trouble finishing this growth according to size algorithm problem. I was able to figure out the first two of the problem which are not listed in the picture. That would ...
2
votes
5answers
448 views
What will be the complexity of this code? Should we sum complexities? [duplicate]
I have an algorithm which ,at first, sorts the vector and then iterate through its elements and XOR them. Should I sum the complexities of sort and for loop to calculate the overall algorithm ...
0
votes
3answers
390 views
How can I learn if an algorithm runs in O(n) time, or O(nlogn)? [duplicate]
How can I learn if an algorithm runs in O(n) time, or O(nlogn)?
-2
votes
1answer
967 views
determine Big-O Notation for functions [duplicate]
In my course of algorithms we talk about time complexity with Big O Notation. And I am always confused when I try to calculate the Big O. I know for example when a function then it can be O(n) or O(n²)...
0
votes
1answer
744 views
Deriving Time Complexity from an algorithm [duplicate]
I am trying to learn about time complexity of an algorithm. My professor has pushed it beyond Big O and wants us to be able to derive an algorithm to a mathematical function. I am having a hard time ...