Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8121595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:32:41+00:00 2026-06-06T05:32:41+00:00

Just a quick preparation for my exam, for example I have: f(x) = 5x<sup>2</sup>

  • 0

Just a quick preparation for my exam, for example I have:

f(x) = 5x<sup>2</sup> + 4x * log(x) + 2

Would the big O be O(x<sup>2</sup> + x * log(x)) or should I take consideration of non-logarithmic coefficients such as 5 or 4?

Likewise, consider this code

for (int i = 0; i < block.length; i++)
    for (int j = 0; j < block.length;  j++)
        for (int k = 0; k < 5; k++)
             g(); //assume worst case time performance of g() is O(1)

So would the big O be O(5n2) or O(n2)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:32:43+00:00Added an answer on June 6, 2026 at 5:32 am

    Complexity for f(x) = 5x^2 + 4xlogx + 2 is O(x^2) because

    O(g(x) + k(x)) = max(O(g(x), k(x))
    // and O(X^2) > O(xlogx)
    
    //additionally coeffs are disregarded
    O(c*g(x)) = O(g(x))
    

    So if you have a sum you just select the largest complexity as at the end of the day, when n goes to infinity the largest component will give the most computational load. It also doesn’t matter if you have any coeffs because you try to roughly estimate what’s going to happen.


    For your other sample see reasoning below

    for (int i = 0; i < block.length; i++)
        for (int j = 0; j < block.length;  j++)
            for (int k = 0; k < 5; k++)
                 g(); //assume worst case time performance of g() is O(1)
    

    First convert loops into sums and work out the sums from right to left

    Sum (i=0,n)
        Sum(j=0, n)
            Sum(k=0, k=5)
                1
    

    Counter of O(1) from 1 to 5 is still O(1), remember you disregard coeffs

    Sum(k=0, k=5) 1 = O(5k) = O(1)
    

    So you end up with the middle sum, which counts a function of O(1) n times, this gives the complexity of O(n)

    Sum(j=0, n) 1 = O(n)
    

    Finally you get to the leftmost sum and notice that you count n n-times, i.e. n+n+n..., which is equal to n*n or n^2

    Sum (i=0,n) n = O(n^2)
    

    So the final answer is O(n^2).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a quick question on working with International Timezones & GMT. I have an
Just a quick question on the memory usage of the play framework. I have
Just a quick check really. I have an XML file that I will be
Just a quick short example of what I'm trying to do: Salamander = {
just a quick question about the mvc JqueryUI framework, i have a _layout.cshtml page
Just a quick question. I have an NSArray that is generated in my applicationDidFinishLaunching
Just a quick example: <p> <span class=example></span> <input type=text name=e_name id=e_id /> </p> <script
just a quick question, if I have a matrix has n rows and m
Just a quick question. I have a system which contains some silverlight elements to
just a quick question here. Lets say I have a stored procedure for seleting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.