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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:19:24+00:00 2026-06-18T06:19:24+00:00

The block is: i=2 while(i<n){ i=i*i; x=x+1; } I need to find the theta

  • 0

The block is:

    i=2  
    while(i<n){  
        i=i*i;  
        x=x+1;  
    }  

I need to find the theta notation for how many times x=x+1 executes. I created a table with some sample values but I can’t figure out how to move on from there. Here are my sample values:

(n) - (# times looped)  
  3 - 1  
  5 - 2  
 20 - 3  
400 - 4
  • 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-18T06:19:25+00:00Added an answer on June 18, 2026 at 6:19 am

    One way to think about this is to trace through the values of i in your loop. Before the first iteration, the value is 2 = 21. After the second iteration, it’s 4 = 22. After the third iteration, it’s 16 = 24. After the fourth iteration, it’s 256 = 28. After the fifth, it’s 65,536 = 216.

    As you can see, after k iterations of the loop, the value of i is 22k. This means that the number of iterations will (roughly) correspond to the lowest value of k such that

    22k ≥ n

    Taking the logarithm of both sides twice, we get

    22k ≥ n

    2k ≥ log2 n

    k ≥ log2 log2 n

    So the number of loop iterations is roughly log2 log2 n. Accordingly, the loop runs O(log log n) times. More precisely, the loop runs Θ(log log n) times, since the loop will not stop until k iterations have elapsed.

    Hope this helps!

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

Sidebar

Related Questions

I'm doing some stuff with SQLite, and I want threads to block while I
in ruby/rails3, I need to do some heavy text parsing to find a certain
There is a problem executing this block of code while passing the parameter. Parameter
How to block google to show our website admin section in search result while
I need a regular expression to uncomment a block of Perl code, commented with
I need your advice. I fetch data from database to table: ID, Name. In
I am writing a multi-threaded .Net application in which many callers need to concurrently
I have an app where I need to prevent users from editing data while
Hi i use the following java code and a sample NSIS script while i
I need to solve this algorithm problem. In the diagram, there are many rows

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.