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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:43:45+00:00 2026-05-23T19:43:45+00:00

I have to find the recurrence equation from this algorithm: ALGO(n) if n <=

  • 0

I have to find the recurrence equation from this algorithm:

    ALGO(n)
    if n <= 2 then return(0)
    else
        y = ALGO(n/3)
        i = 2^n
        while i >= 2 do
            j = (1/2) * log(i) //base 2
            while j > 0 do
                i = i/2
                j = j - 1
        z = ALGO(n/2)
        return(z+y) 

I reasoned about it and concluded that
T(n) = O(1) if n<=2

I think that the inner while is an O(n) (j is decreased by 1 at each iteration) while the outer while is an O(logn) (the i is halved at each iteration), giving an O(n*log(n)):

T(n) = T(n/3) + T(n/2) + O(n*log(n)) if n > 2

Is this a good argument?

  • 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-23T19:43:45+00:00Added an answer on May 23, 2026 at 7:43 pm

    The two while loop should be O(n):

    1. i = 2^n;
    2. j = (1/2) * log (i) = 1/2 * n = n/2
    3. the inner while executes for n/2 times then j becomes 0, now i = i / 2^(n/2) = 2^(n/2);
    

    Now this program will go back to step 1, only with i halved. So the two loops should be:

    n/2+n/4+n/8+... = O(n)
    

    In fact this could also be viewed from a simpler perspective. Since the loop won’t terminate until i == 1, and for every execution i = i / 2, the inner loop will run n times. Imagine we flatten the inner loop and the out loop, there will be n times of i = i / 2, hence the two loops are O(n).

    In conclusion, T(n) = T(n/3) + T(n/2) + O(n).

    Hope this could be helpful!

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

Sidebar

Related Questions

We have to create an algorithm and find and solve its recurrence. Finding the
I have find more answer about this, but return error The option prova does
I have a Find function in order to find an element from a BST
I have to find the code blocks from the given code using a regex
Here is the problem: I have to find a path from the starting point
I have a string. I have to find a specific part of this string.
Suppose I have a linear recurrence* and I want to find its closed-form 'Binet'
I have to find current url and if it is equal to http://localhost/mysite then
I am evaluating datamining packages. I have find these two so far: RapidMiner Weka
I have to find the IDs of all the contentPlaceHolders in a MasterPage.

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.