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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:49:29+00:00 2026-06-18T19:49:29+00:00

I know there is many similar questions about the Big Oh notation, but this

  • 0

I know there is many similar questions about the Big Oh notation, but this example is quite interesting and not trivial:

int sum = 0;
for (int i = 1; i <= N; i = i*2)
    for (int j = 0; j < i; j++)
        sum++;

The outer loop will iterate lg(N) times, but what with inner loop? And what is T(N) for all the operations?
I can see only 3 posibilities :

  • T(N) = lg(N) * 2^N
  • T(N) = log(N) * (N-1)
  • T(N) = N

My opinion – T(N) = N – but it is just my intuition from observations value of sum variable when N was multiplied many times – sum was almost equal to 2N, which gives us N.

Basically I do not know how to count it. Please help me with this task and explain the solution – it is quite important for me.

Thanks

  • 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-18T19:49:30+00:00Added an answer on June 18, 2026 at 7:49 pm

    The inner loop iterates the last time max. N. Before the last run it iterates N/2. If you sum it up N + N/2 + N/4 + N/8 This add up to 2*N. And that’s all as you counted all runs. T(N) = N

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

Sidebar

Related Questions

There are many similar questions to this one, but they all ask about setting
I know there are multiple similar questions about this error, and I've tried many
I know there are many questions similar but any of them didn't help. in
NOTE: I know there are many questions that talked about that but I'm still
I know there are many similar questions. But I am specifically looking to see
As far as i know there are many other questions similar to title, but
There are many similar questions, but I've tried about 15 different preg_match examples and
I know there are already many questions like mine but I found no answer
I know that there are similar questions which are already answered, but I am
Yep there are many similar questions, but I really couldn't solve my problem. Unfortunately

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.