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

The Archive Base Latest Questions

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

I am trying to find the running time O(n) for the block of code

  • 0

I am trying to find the running time O(n) for the block of code below:

int z=0;
int x=0; 
for (int i=1; i<=n; i=i*3){ //runs from 1->n, 1, 3, 9, 27... <- fcn that defines this?
   //constant running times below
   z = z+5;
   z++;
   x = 2*x;
}

if it was i=i*2, then it would be logn complexity running time. What is it for this case?

tia.

  • 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:18:37+00:00Added an answer on June 5, 2026 at 10:18 pm

    Notice that log_3 (n) = log_2 (n) / log_2 (3) . Here log_2 means log with base 2 and log_3 means log with base 3. So, log_2(n) is just log_3(n) times a constant.

    So, by big O definition, any code which has running time O(log_3(n)) is also O(log(n)).

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

Sidebar

Related Questions

I'm trying to find out why this entire code below is producing only ONE
I'm trying to find more information on how to bound the running time of
I am trying to find the relative memory usage of each running application and
Trying to find an example that has css rollover using sprites & sliding door
Trying to find a way to send a POST HTTPS request from Python to
Been trying to find this online for a while now. I have a SDL_Surface
Im trying to find records in a VARCHAR column that may contain a NUL
I have a problem that I have been trying to find a solution for
I'm attempting to find the difference in running time between multi and single core
I've been trying to find a reliable way to get the length of time

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.