Questions tagged [big-o]

The Big-O notation is used to represent asymptotic upper bounds. It describes relevant time or space complexity of algorithms. Big-O analysis provides a coarse and simplified estimate of a problem difficulty.

The Big-O notation is used to represent asymptotic upper bounds. It describes relevant time or space complexity of algorithms. Big-O analysis provides a coarse and simplified estimate of a problem difficulty.

Other Questions

Further Reading

137 questions
3
votes
1 answer

What exactly is "big O" notation?

From what I've gathered, big O notation is used to describe the length of an operation. However, that's as far as I've gotten. What exactly is big O notation and how do the most common ones (O(n), O(2n), O(n^2), O(log n), etc)?
Cole Tobin
  • 1,469
2
votes
1 answer

Help with Big-O notation complexity

How do I find the O - notation complexity for the following? int sum = 0; for (int i = 1; i <= n*2; i++ ) sum++; I read the guide on Big - O and other posts on Big -O complexity, but I'm still lost.
ixbo45
  • 129
2
votes
2 answers

O(n^2 * 2^(log n)) == O(n^2)

Is O(n^2 * 2^(log n)) == O(n^2) ? Why I think that this could be the case: In big O, you only take the parts of the term that are most relevant, right? O(n^2 + 3n + 9) == O(n^2). The n^2 has a lot more influence to the result of the term than the…
palsch
  • 171
1
vote
5 answers

BIG O - Algorithm Case Analysis

Why is big O most commonly associated with worst and average case complexties of a function
user23871
  • 343
1
vote
1 answer

omega why K + N better than N

I was reviewing the big O cheatsheet at http://bigocheatsheet.com/ and ran into some listings under sort that I do not understand. Runtimes are color coded, green being better than yellow. There are cases where Ω(N) is color coded better than…
1
vote
2 answers

Understanding θ(f(n)) as defined in the Structure and Interpretation of Computer Programs

I'm having trouble understanding a small passage in The Structure and Interpretation of Computer Programs, and I'm hoping someone can help me interpret it. In the book's introduction to Orders of Growth (Big O Stuff--Page 48 in volume 2) the book…
ebrts
  • 477
1
vote
1 answer

Expressing complexity based on length of key

I've made a data structure that has insert, search, and delete functions that are base on the number of characters in the key. As an example if it's a number based key (base10), then the complexity for the given functions is at worst equal to the…
1
vote
1 answer

How should I express the complexity of two nested loops over different datasets in Big O notation?

I'm more or less teaching myself big O notation, so please forgive me if this is a duplicate of a question which applied to my question without me having the wisdom to realise it. For my own amusement/personal development, I'm trying to express the…
Toadfish
  • 141
1
vote
3 answers

Big O Notation of an example

My professor gave this example in a lecture: Example: Given an integer N, print out the values 1…N. for (int i=1; i<=N; i=i+1) { System.out.print(i); } The professor said that the loop was O(n) because it printed the values 1 to N. However I…
RedLaser
  • 121
1
vote
2 answers

How does big O notation indicate upper bound on a function?

Suppose we have a function, f(n)=n+10. We say that f(n)∈O(n), meaning O(n) represents the upper bound of the function. It is also true that f(n)∈O(n2) or f(n)∈O(n3) and so on. So how can we say that O(n) is the upper bound when O(n2) is…
1
vote
2 answers

Constants and Big O

Are constants always irrelevant even if they are large? For example is O(10^9 * N) == O(N) ?
-1
votes
1 answer

Big O of loop of 0...n with nested loop doing k iterations

My coworkers and I are discussing this code and need a third party to settle our discussion :) Random randNum = new Random(); int[] A = Enumerable.Repeat(0, 1000).Select(i => randNum.Next(0, 100)).ToArray(); int k = randNum.Next(0, A.Length); int[]…
-3
votes
1 answer

What is the O of this operation?

Say for a given positive integer number n, you have to find a level k so that 1 + 2 + 3 + ... + k = S is below or equals n but S + k + 1 is above n. For example in python: def find_level(n): level = 1 while n > 0: n -= level …