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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:52:34+00:00 2026-05-15T12:52:34+00:00

Is there someone that knows what the computational cost for this two pieces of

  • 0

Is there someone that knows what the computational cost for this two pieces of code is?

while (n > 2)
   n = sqrt(n);

while (n > 2)
   n = log(n);
  • 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-05-15T12:52:34+00:00Added an answer on May 15, 2026 at 12:52 pm

    The second would be O(log* n) where log * is the iterated logarithm.

    Analysing the first one yields something like this:

    sqrt(n) = n ^ (1/2)
    sqrt(sqrt(n)) = n ^ (1/4)
    sqrt(sqrt(sqrt(n))) = n ^ (1/8)
    ...
    sqrt applied k times = n ^ (1/2^k)
    

    Consider that the first algorithm executes k times (basically, the number of times we have to apply sqrt until n <= 2).

    Consider this reasoning:

    n ^ (1/2^k) = p (p <= 2) | ^ (2^k)
    n = p ^ (2^k) | log
    log n = (2^k) log p | log
    log log n = log (2 ^ k) + log log p
    log log n = klog2 + log log p
    => k ~= log log n
    

    So the first algorithm is O(log log n).

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

Sidebar

Related Questions

There is some code that I am using written by someone else that I
Recently I was repairing someone's code. There was a big class that would not
There is someone in my team that swears by using some kind of GVim
Is there a php function that someone can use to automatically detect if an
is there any custom asp.net membership providers that someone has already created online. I
In a recent discussion on ORMs for webapps someone mentioned that there are times
Is there any way that I can make it so when someone clicks save
If there is some sort of debugging API that would allow someone to write
Is there a log4net version built against Silverlight somewhere? Failing that, can someone suggest
Is there any codeplex license that allows some one to use my code any

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.