Is there a specific method to calculate these values?

No.

In the case you explain though, for every , hence and fit.

Likewise (exercise), and would fit. Or and . Or many others.

Answer from Did on Stack Exchange
🌐
Story of Mathematics
storyofmathematics.com › math-calculators › big-o-calculator
Big O Calculator + Online Solver With Free Steps
November 22, 2023 - Big O Calculator is an online tool that helps you compute the complexity domination of two algorithms. It tells the growth rate of a function.
🌐
Wolfram|Alpha
wolframalpha.com › widgets › view.jsp
Wolfram|Alpha Widgets: "Big-O Domination Calculator" - Free Computational Sciences Widget
February 7, 2015 - Get the free "Big-O Domination Calculator" widget for your website, blog, Wordpress, Blogger, or iGoogle. Find more Computational Sciences widgets in Wolfram|Alpha.
Discussions

algorithms - Big-O Notation (How to calculate C and k) - Mathematics Stack Exchange
I have a fair idea of what Big-O Notation is, but I'd like to know if there's a sure fire way to calculate the values of C and k for which Example question: Via trial and error, I have found them ... More on math.stackexchange.com
🌐 math.stackexchange.com
December 31, 2014
algorithm - how do *you* calculate/approximate Big O? - Stack Overflow
Most people with a degree in CS know what Big O stands for. It helps us to measure how well an algorithm scales. How do you calculate or approximate the complexity of your algorithms? More on stackoverflow.com
🌐 stackoverflow.com
Discrete Math - Big O notation
After dividing the numerator and denominator by x3 we get: (7x - 5 + 4/x2 - 10/x3 ) / (4 - log(x)2 / x3 - 3/x2 ) Dropping all of the terms that go to 0 gives (7/4)x - 5/4, which is O(x). More on reddit.com
🌐 r/learnmath
11
5
October 24, 2019
C960 - Discrete Math II - Big O Notation Resources?
The only tip I really have is watch for loops. I feel like all I really did is look for those in the psuedocode. If there's no loops at all it should be O(1). If theres a single loop on the data, it should be just O(n). if its looping the data again for each one of the data (like a loop inside a loop), it's O(n2). For O(log n) the main thing I would look for is something that's reducing how many times it loops so it's not doing it for each piece of data - If something isnt going to loop over every single item (and gets smaller as the loops continue) it's not O(n). More on reddit.com
🌐 r/WGU_CompSci
8
7
February 10, 2024
🌐
Mathematics LibreTexts
math.libretexts.org › campus bookshelves › saint mary's college › smc: math 339 - discrete mathematics (rohatgi) › 4: algorithms
4.1: Big-O Notation - Mathematics LibreTexts
April 22, 2021 - To show that one function is big-O of another, we must produce the constants \(M\) and \(k\). ... Show that \(f(x)=x^2+3x-2\) is \(O(x^3)\). ... We notice that as long as \(x> 1\), \(x^2\le x^3\) and \(3x-2\le x^3\). Therefore, when \(x> 1\), we have that \(|f(x)|=x^2+3x-2\le 2x^3\). So we choose \(k=1\) and \(M=2\). There are infinitely many other choices for pairs \(k,M\) that would work as well.
🌐
Big O Calc
bigocalc.com
Big O Calc
Click Calculate to analyze the time and space complexity using Big O notation. Review the result — you'll get a step-by-step breakdown of how the complexity was determined. Tip: Keep your code under 1,500 characters for best results. Focus on the core algorithm rather than boilerplate code. ... Learn the details in our comprehensive guide. ... function binarySearch(arr, target) { let left = 0, right = arr.length - 1; while (left <= right) { const mid = Math.floor((left + right) / 2); if (arr[mid] === target) return mid; if (arr[mid] < target) left = mid + 1; else right = mid - 1; } return -1; }
🌐
Mathematics LibreTexts
math.libretexts.org › campus bookshelves › monroe community college › mth 220 discrete math › 8: big o
8.1: Big O - Mathematics LibreTexts
July 27, 2020 - Choose \(n=1\), i.e. \(x \geq 1.\) \(|4x^3-11x^2+3x-2 |\leq |4x^3|+|-11x^2|+|3x|+|-2| \qquad \mbox{ by the Triangle Inequality Theorem}\) \(\qquad \qquad \qquad \qquad \qquad=4x^3+11x^2+3x+2 \qquad \mbox{ applying absolute value; note: }x \mbox{ is positive}\) \(\qquad \qquad \qquad \qquad \qquad\leq 4x^3+11x^3+3x^3+2x^3 \qquad \mbox{ since }x \mbox{ is positive and greater than 1}\) \(\qquad \qquad \qquad \qquad \qquad =20x^3\) \(\qquad \qquad \qquad \qquad \qquad=20|x^3|\qquad \mbox{ since }x \mbox{ is positive and greater than 1}\) Thus for all \(x \geq 1,\) \(|4x^3-11x^2+3x-2 | \leq 20|x^3|\) Therefore, using \(n=1\) and \(k=20\), \(4x^3-11x^2+3x-2=O(x^3)\) by the definition of Big O. Big O is used to compare the growth rates of functions.
🌐
Desmos
desmos.com › calculator › kgwiv5zizm
big-o growth | Desmos
Explore math with our beautiful, free online graphing calculator. Graph functions, plot points, visualize algebraic equations, add sliders, animate graphs, and more.
Find elsewhere
🌐
Wolfram MathWorld
mathworld.wolfram.com › Big-ONotation.html
Big-O Notation -- from Wolfram MathWorld
April 11, 2014 - The symbol O(x), pronounced "big-O of x," is one of the Landau symbols and is used to symbolically express the asymptotic behavior of a given function. In particular, if n is an integer variable which tends to infinity and x is a continuous ...
🌐
YouTube
youtube.com › watch
Discrete Math: Big-O Examples and Theorems - YouTube
Derivation of the big-O estimates for various functions as well as a few examples of applying theorems.***For examples skip to 16:07 ******View the theorems ...
Published   September 25, 2018
🌐
Quora
quora.com › How-do-I-calculate-the-Big-oh-notation-of-a-function
How to calculate the Big-oh notation of a function - Quora
Answer (1 of 3): If the function is not too unweildy, it's pretty easy to do. Consider the function f(x) = 4x^3 + (7x^2)(log(x)) + 3x +8 Lokk for the highest order term - the term that grows faster than the other terms, as x gets larger. For this function, that term is 4x^3. Now just get rid ...
🌐
YouTube
youtube.com › watch
Big O notation made easy - YouTube
Live online mathematical workshops via Zoom.See www.heyman.com.au for more information. Solutions to three typical test or exam questions. Sometimes called ...
Published   July 9, 2015
🌐
MIT
web.mit.edu › 16.070 › www › lecture › big_o.pdf pdf
Big O notation (with a capital letter O, not a zero), also ...
Note, too, that O(log n) is exactly the same as O(log(nc)). The logarithms differ only by a · constant factor, and the big O notation ignores that.
🌐
Vercel
big-o-calculator.vercel.app
Big O Calculator
Calculate the time and space complexity of your code with this powerful app. Get insights into the efficiency of your algorithms and optimize them for better performance. Try it now!
Top answer
1 of 16
1562

I'll do my best to explain it here on simple terms, but be warned that this topic takes my students a couple of months to finally grasp. You can find more information on the Chapter 2 of the Data Structures and Algorithms in Java book.


There is no mechanical procedure that can be used to get the BigOh.

As a "cookbook", to obtain the BigOh from a piece of code you first need to realize that you are creating a math formula to count how many steps of computations get executed given an input of some size.

The purpose is simple: to compare algorithms from a theoretical point of view, without the need to execute the code. The lesser the number of steps, the faster the algorithm.

For example, let's say you have this piece of code:

int sum(int* data, int N) {
    int result = 0;               // 1

    for (int i = 0; i < N; i++) { // 2
        result += data[i];        // 3
    }

    return result;                // 4
}

This function returns the sum of all the elements of the array, and we want to create a formula to count the computational complexity of that function:

Number_Of_Steps = f(N)

So we have f(N), a function to count the number of computational steps. The input of the function is the size of the structure to process. It means that this function is called such as:

Number_Of_Steps = f(data.length)

The parameter N takes the data.length value. Now we need the actual definition of the function f(). This is done from the source code, in which each interesting line is numbered from 1 to 4.

There are many ways to calculate the BigOh. From this point forward we are going to assume that every sentence that doesn't depend on the size of the input data takes a constant C number computational steps.

We are going to add the individual number of steps of the function, and neither the local variable declaration nor the return statement depends on the size of the data array.

That means that lines 1 and 4 takes C amount of steps each, and the function is somewhat like this:

f(N) = C + ??? + C

The next part is to define the value of the for statement. Remember that we are counting the number of computational steps, meaning that the body of the for statement gets executed N times. That's the same as adding C, N times:

f(N) = C + (C + C + ... + C) + C = C + N * C + C

There is no mechanical rule to count how many times the body of the for gets executed, you need to count it by looking at what does the code do. To simplify the calculations, we are ignoring the variable initialization, condition and increment parts of the for statement.

To get the actual BigOh we need the Asymptotic analysis of the function. This is roughly done like this:

  1. Take away all the constants C.
  2. From f() get the polynomium in its standard form.
  3. Divide the terms of the polynomium and sort them by the rate of growth.
  4. Keep the one that grows bigger when N approaches infinity.

Our f() has two terms:

f(N) = 2 * C * N ^ 0 + 1 * C * N ^ 1

Taking away all the C constants and redundant parts:

f(N) = 1 + N ^ 1

Since the last term is the one which grows bigger when f() approaches infinity (think on limits) this is the BigOh argument, and the sum() function has a BigOh of:

O(N)

There are a few tricks to solve some tricky ones: use summations whenever you can.

As an example, this code can be easily solved using summations:

for (i = 0; i < 2*n; i += 2) {  // 1
    for (j=n; j > i; j--) {     // 2
        foo();                  // 3
    }
}

The first thing you needed to be asked is the order of execution of foo(). While the usual is to be O(1), you need to ask your professors about it. O(1) means (almost, mostly) constant C, independent of the size N.

The for statement on the sentence number one is tricky. While the index ends at 2 * N, the increment is done by two. That means that the first for gets executed only N steps, and we need to divide the count by two.

f(N) = Summation(i from 1 to 2 * N / 2)( ... ) = 
     = Summation(i from 1 to N)( ... )

The sentence number two is even trickier since it depends on the value of i. Take a look: the index i takes the values: 0, 2, 4, 6, 8, ..., 2 * N, and the second for get executed: N times the first one, N - 2 the second, N - 4 the third... up to the N / 2 stage, on which the second for never gets executed.

On formula, that means:

f(N) = Summation(i from 1 to N)( Summation(j = ???)(  ) )

Again, we are counting the number of steps. And by definition, every summation should always start at one, and end at a number bigger-or-equal than one.

f(N) = Summation(i from 1 to N)( Summation(j = 1 to (N - (i - 1) * 2)( C ) )

(We are assuming that foo() is O(1) and takes C steps.)

We have a problem here: when i takes the value N / 2 + 1 upwards, the inner Summation ends at a negative number! That's impossible and wrong. We need to split the summation in two, being the pivotal point the moment i takes N / 2 + 1.

f(N) = Summation(i from 1 to N / 2)( Summation(j = 1 to (N - (i - 1) * 2)) * ( C ) ) + Summation(i from 1 to N / 2) * ( C )

Since the pivotal moment i > N / 2, the inner for won't get executed, and we are assuming a constant C execution complexity on its body.

Now the summations can be simplified using some identity rules:

  1. Summation(w from 1 to N)( C ) = N * C
  2. Summation(w from 1 to N)( A (+/-) B ) = Summation(w from 1 to N)( A ) (+/-) Summation(w from 1 to N)( B )
  3. Summation(w from 1 to N)( w * C ) = C * Summation(w from 1 to N)( w ) (C is a constant, independent of w)
  4. Summation(w from 1 to N)( w ) = (N * (N + 1)) / 2

Applying some algebra:

f(N) = Summation(i from 1 to N / 2)( (N - (i - 1) * 2) * ( C ) ) + (N / 2)( C )

f(N) = C * Summation(i from 1 to N / 2)( (N - (i - 1) * 2)) + (N / 2)( C )

f(N) = C * (Summation(i from 1 to N / 2)( N ) - Summation(i from 1 to N / 2)( (i - 1) * 2)) + (N / 2)( C )

f(N) = C * (( N ^ 2 / 2 ) - 2 * Summation(i from 1 to N / 2)( i - 1 )) + (N / 2)( C )

=> Summation(i from 1 to N / 2)( i - 1 ) = Summation(i from 1 to N / 2 - 1)( i )

f(N) = C * (( N ^ 2 / 2 ) - 2 * Summation(i from 1 to N / 2 - 1)( i )) + (N / 2)( C )

f(N) = C * (( N ^ 2 / 2 ) - 2 * ( (N / 2 - 1) * (N / 2 - 1 + 1) / 2) ) + (N / 2)( C )

=> (N / 2 - 1) * (N / 2 - 1 + 1) / 2 = 

   (N / 2 - 1) * (N / 2) / 2 = 

   ((N ^ 2 / 4) - (N / 2)) / 2 = 

   (N ^ 2 / 8) - (N / 4)

f(N) = C * (( N ^ 2 / 2 ) - 2 * ( (N ^ 2 / 8) - (N / 4) )) + (N / 2)( C )

f(N) = C * (( N ^ 2 / 2 ) - ( (N ^ 2 / 4) - (N / 2) )) + (N / 2)( C )

f(N) = C * (( N ^ 2 / 2 ) - (N ^ 2 / 4) + (N / 2)) + (N / 2)( C )

f(N) = C * ( N ^ 2 / 4 ) + C * (N / 2) + C * (N / 2)

f(N) = C * ( N ^ 2 / 4 ) + 2 * C * (N / 2)

f(N) = C * ( N ^ 2 / 4 ) + C * N

f(N) = C * 1/4 * N ^ 2 + C * N

And the BigOh is:

O(N²)
2 of 16
216

Big O gives the upper bound for time complexity of an algorithm. It is usually used in conjunction with processing data sets (lists) but can be used elsewhere.

A few examples of how it's used in C code.

Say we have an array of n elements

int array[n];

If we wanted to access the first element of the array this would be O(1) since it doesn't matter how big the array is, it always takes the same constant time to get the first item.

x = array[0];

If we wanted to find a number in the list:

for(int i = 0; i < n; i++){
    if(array[i] == numToFind){ return i; }
}

This would be O(n) since at most we would have to look through the entire list to find our number. The Big-O is still O(n) even though we might find our number the first try and run through the loop once because Big-O describes the upper bound for an algorithm (omega is for lower bound and theta is for tight bound).

When we get to nested loops:

for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
        array[j] += 2;
    }
}

This is O(n^2) since for each pass of the outer loop ( O(n) ) we have to go through the entire list again so the n's multiply leaving us with n squared.

This is barely scratching the surface but when you get to analyzing more complex algorithms complex math involving proofs comes into play. Hope this familiarizes you with the basics at least though.

🌐
Reddit
reddit.com › r/learnmath › discrete math - big o notation
r/learnmath on Reddit: Discrete Math - Big O notation
October 24, 2019 -

I been trying to figure this out for the past hour and I'm having trouble starting the problem. The examples my professor be teaching us are way simpler than this. :\

I'm trying to find the "big O estimate for functions f(x), x∈R" where f(x) = (7x4- 5x3 + 4x -10) / (4x3 - logx2 -3x )

Any hints would be much appreciated.

🌐
Quora
quora.com › What-is-the-big-O-notation-and-how-do-I-calculate-it-Will-you-give-me-examples-of-code-and-their-corresponding-representations-in-O-notation
What is the big O notation and how do I calculate it? Will you give me examples of code and their corresponding representations in O notation? - Quora
Answer (1 of 16): Say that you need to perform a task, and that there are 2 methods for performing that task. It means that there are 2 algorithms, say A and B, for performing that same task. Let A finish the task in time TA and B finishes it in time TB. If we can show that TA is less than TB, t...
🌐
PyPI
pypi.org › project › big-O-calculator
big-O-calculator 0.1.0
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Calcworkshop
calcworkshop.com › home › functions › big o
Big-O (Fully Explained in Detail w/ Step-by-Step Examples!)
April 1, 2023 - In our previous lesson, we learned how to successfully identify whether a function is big-O (upper bound), big-omega (lower bound), or big-theta (tight bound) using the Asymptotic Limit Theorem. Now, it’s up to us to sagely choose our witnesses, or positive constants \(c\) and \(k\), that prove \(f(x)\) is \(\Theta \left( {g\left( x \right)} \right)\),\(\Omega \left( {g\left( x \right)} \right)\) or both (i.e., \(\Theta \left( {g\left( x \right)} \right)\)). Use the Asymptotic limit Theorem to determine the growth of a function for large input values: \(\mathop {\lim }\limits_{n \to \infty } \left( {\frac{{f\left( x \right)}}{{g\left( x \right)}}} \right) = 0\) , then \(f\left( x \right)\) is \(O\left( {g\left( x \right)} \right)\) (Big-O)
🌐
Medium
medium.com › dataseries › how-to-calculate-time-complexity-with-big-o-notation-9afe33aa4c46
How To Calculate Time Complexity With Big O Notation | by Maxwell Harvey Croy | DataSeries | Medium
July 28, 2020 - How To Calculate Time Complexity With Big O Notation Part 2 of a series breaking down Big O Notation and Time and Space Complexity for new developers. If you’re on your way to becoming a software …
🌐
Reddit
reddit.com › r/wgu_compsci › c960 - discrete math ii - big o notation resources?
r/WGU_CompSci on Reddit: C960 - Discrete Math II - Big O Notation Resources?
February 10, 2024 -

Reposting quick cuz I used the wrong class number.

I am finishing up DMII and I have every unit locked down, exemplary and competent in all, on the PA except for the first unit. Specifically, I am having a hard time reading the algorithms and answering which Big O Notation the algorithm's run time is. It's just not clicking.

I've tried some of the popular youtube videos. I've searched this subreddit and Reddit and outside the class material, Big O makes sense. The videos I watch make sense. But it's when I'm given questions regarding Big O Notation does it not click well.

There are six questions on the PA about Big O Notation and Analyzing Algorithms and I don't think I can skate by by just guessing so I'm trying to get this down a bit more. Any tips?

Top answer
1 of 7
18
The only tip I really have is watch for loops. I feel like all I really did is look for those in the psuedocode. If there's no loops at all it should be O(1). If theres a single loop on the data, it should be just O(n). if its looping the data again for each one of the data (like a loop inside a loop), it's O(n2). For O(log n) the main thing I would look for is something that's reducing how many times it loops so it's not doing it for each piece of data - If something isnt going to loop over every single item (and gets smaller as the loops continue) it's not O(n).
2 of 7
4
The main thing you are looking for is loops. Here is how i look at most of these problems -For algorithms with no dependency on input size, the complexity is O(1). - A single loop over N elements has O(N) complexity. - Nested loops result in polynomial complexity (O(N^2), O(N^3), etc.), depending on the nesting depth. - Algorithms that reduce the problem size by a factor at each step have O(log N) complexity. (aka If there is a division by 2 on the count) The only thing that matters is the Biggest N. So if you have O(N^2) + O(N) you can ignore the O(N) Here's an example of a for loop in pseudocode demonstrating linear time complexity O(N): for i = 1 to N do print "This is operation number", i O(N^2) - Example: Nested Loops - Notice the nested loops. If you had a 3rd nested loop it would be O(N^3): for i = 1 to N do for j = 1 to N do print "Operation (", i, ",", j, ")" O(log N) - Example: Binary Search - (notice the division by 2 in the loop) function binarySearch(array, targetValue) is low = 1 high = length(array) while low <= high do mid = (low + high) / 2 if array[mid] == targetValue then return mid else if array[mid] < targetValue then low = mid + 1 else high = mid - 1 return -1 // targetValue not found Good Luck on your studying!