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 8099959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:34:56+00:00 2026-06-05T22:34:56+00:00

See solution below, I would like some constructive feedback. what is the running time

  • 0

See solution below, I would like some constructive feedback.

what is the running time in O(n) below.

int a = 0;
int k = n*n*n; //n^3
while(k > 1) 
{
  for (int j=0; j<k; j++) //runs from 0->k
  { a--; }
k = k/2; //divides by 2 each iteration
}

each time the for loop runs, it gives a constant x k.

= 0xn^3 + 1x (n^3/2) + 2x(n^3/4) +…+ nx(n^3/2^n)
= n^3 (0 + 1/2 + 2/4 +…+ n/2^n) <- anyone know how I can simplify this down further?

Edit: i am assuming we would use the arithmetic series somehow….

  • 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-05T22:34:58+00:00Added an answer on June 5, 2026 at 10:34 pm

    Let’s use k first

    in first while loop, the for loop runs k times

    in second while loop, the for loop runs k/2 times

    in third while loop, the for loop runs k/4 times

    …

    so in total it runs ( k + k/2 + k/4 + k/8 + … + 1) times

    after extract the k, it’s k * ( 1 + 1/2 + 1/4 + 1/8 + … + 1/k)

    as k increases, the part in parentheses becomes 2, which we can ignore

    change k to n^3, the result is O(n^3)

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

Sidebar

Related Questions

Solution: API 11 is needed see answer below! Easy Question: After downloading a File
Just posting the solution I worked out today. See my answer below. If you
I have an attribute in my model which contains html string like below: <p>Solution
Note, I have found the solution to my problem. Please see below. I'm converting
For a possible solution using Active Directory and Exchange see my post below. We
UPDATE: I actually found the solution myself, see below. In R I want to
Update: found a solution, see below. I'm trying to get a clicked tile div
Intro: EDIT: See solution at the bottom of this question (c++) I have a
i have a little problem and see no solution for it. I need flexible
I've seen many similar errors, but I can't see a solution that applies to

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.