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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:49:07+00:00 2026-06-06T16:49:07+00:00

Yesterday I applied for computer engineering master degree and it was the one of

  • 0

Yesterday I applied for computer engineering master degree and it was the one of the their questions. I could not solve it so I was very curious.

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

How many times will this while loop get executed, please give your answer as a formula. For ex: log n…

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-06T16:49:09+00:00Added an answer on June 6, 2026 at 4:49 pm

    On the xth iteration of the loop, i equals 2x (you can easily prove this by induction). Suppose the loop stops after X iterations, which means n < 2X. This also means that on iteration X-1 the loop was still running and so 2X-1 ≤ n. In other words :

    2X-1 ≤ n < 2X

    From there, finding X as a function of log2(n) is easy.

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

Sidebar

Related Questions

Yesterday I asked this general question about decimals and their internal precisions. Here is
Yesterday I have been testing one single query for over hours and hours, but
Yesterday Oracle decided to take down java.sun.com for a while. This screwed things up
yesterday i asked one question and got the answer from our friend here, and
Yesterday I ran into an issue with PHP's strtotime not properly adding a month.
Yesterday I was working using MySQL installed on my computer. I downloaded xampp, so
Yesterday I updated to firefox 13 and I notice that this property is not
Yesterday, I could deploy my services perfectly fine to the hosted service instance on
since yesterday at my workplace, I could no longer visit any external sites apart
Yesterday I tried RadPHP, it looks very similar to Delphi with it's properties which

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.