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

  • SEARCH
  • Home
  • 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 8909877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:32:44+00:00 2026-06-15T03:32:44+00:00

I have being given the following question and can’t decide the right answer: for

  • 0

I have being given the following question and can’t decide the right answer:

for (int i=1; i<=n/2; i++)
  for(int j=i; j<=n-i;j++)
    for(int k=i;k<=j;k++)
      x++;

What’s the order of growth of the x as a function of n?

  1. Ω(n^3).
  2. Θ(n^2.5)
  3. Θ(n^2)
  4. Ο(nlogn)
  5. none of the above

I managed to figure out that:

T(n) = n*(n-1) + T(n-2)

but this doesn’t really help me figure out the order of growth.
maybe there is a better way of finding it?

  • 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-15T03:32:46+00:00Added an answer on June 15, 2026 at 3:32 am

    This looks like a homework problem so I will just give you hints.

    1) Suppose you just have the inner loop. How many times do you go through the inner loop, as a function of i and j? How many operations are performed every iteration of the loop? How many operations should be performed total?

    2) Now suppose you just have the inner two loops. How many times do you go through the outer loop, as a function of i and n? How many times do you go through the inner loop every time you go through the outer loop? (hint: this should be different depending on what j is) How many operations should be performed total?

    3) Now you are ready to look at the entire problem. How many times do you go through the inner two loops (as a function of n), and how many operations should be performed on each iteration? How many operations are performed total? (That’s your answer)


    Okay, you say this isn’t a homework problem, and actually it’s harder than I thought it was, so I’ll just give you the answer.

    Each inner loop runs in time j – i.

    The second loop runs in time (i – i) + (i + 1 – i) + … + (i + n – 2i – i) = 1 + 2 + … + (n – 2i) = (n – 2i)(n – 2i + 1)/2, by mathematical induction.

    When calculating order of growth, the 1 term is very small compared to the n, so the outer loop runs in approximately n^2/2 + (n-2)^2/2 + (n-4)^2/2 + … + 1/2.

    This is approximately one fourth of 1^2 + 2^2 + … + n^2, which by induction is n(n+1)(2n+1)/6. Therefore the order of growth is Omega(n^3).

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

Sidebar

Related Questions

Given models User and Comments being populated such that a user may have many
Being fairly new to C++ I have a question bascially concerning the g++ compiler
Consider the following, I have paragraph data being sent to a view which needs
Being a new to WPF/XAML/MVVM, I've got a question. In my View, I have
Say that I have the following code: function testA { setTimeout('testB()', 1000); doLong(); }
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
Hi I have asked this question yesterday and was closed of being not understood,
I have descriptions being displayed within an XML document and then loading it into
I have data being recorded every 15 minutes into the PowerStringHistorys and PowerCombinerHistorys tables.
I have a CustomerID being retrieved and set into a Global Variable. What I

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.