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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:52:53+00:00 2026-06-12T19:52:53+00:00

I understand how to find the time complexity of an algorithm when I’ve been

  • 0

I understand how to find the time complexity of an algorithm when I’ve been presented with an algorithm, but I can’t seem to get my head around how to work it out when I’ve been given the number of times the algorithm is executed, and the time taken.

I can sometimes get it, when it’s obvious things like O(n), O(n) or O(n^2) but take this question for example:

An algorithm runs a given input of size n.
If n is 4096 the run time is 512 milliseconds.
If n is 16384 the run time is 1024 milliseconds.
If n is 36864 the run time is 1536 milliseconds.

What is the time complexity?

I see that as n * 2, t * 1.5, but I’m not quite sure how to work it out.

Thank you for your help 🙂

  • 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-12T19:52:54+00:00Added an answer on June 12, 2026 at 7:52 pm

    I would say you need more than just three datapoints for this kind of question, because of complexities in the system rather than just the algorithm.

    What I would do is compare the iterations and the elapsed time and see if you can find a pattern that matches one of the standard time complexities:

    • Constant: O(c) where c is a constant.
    • Linear: O(n)
    • Polynomial: O(n^c) where c is a constant (or even something complicated like O(n^2 + n^6))
    • Exponential: O(c^n) where c is a constant.
    • Logarithmic: O(log|n|)
    • Whatever this is called: O(n log|n| )

    Let’s go through your problem:

    n     | time
    4096  | 512 ms
    16384 | 1024 ms
    36864 | 1536 ms
    

    When n goes up by a factor of 4 (from 4096 to 16384), the time goes up by a factor of 2 (from 512 to 1024 ms).

    When n goes up by a factor of 9 (from 4096 to 36864), the time goes up by a factor of 3 (from 512 to 1536 ms).

    A function that matches this is f(n) = n^(1/2). When n goes up by a factor of 4, f(n) goes up by a factor of sqrt(4), etc…

    So this is of order O(n^.5), which is polynomial

    TLDR: Graph it out and match it to a common function for time-complexity. In the real-world you would probably need more than three datapoints.

    edit: I’d like to add that that this should really be more complex. There is likely a constant term in every kind of time complexity. I.e. O(n^c) is more likely O(n^c + K) where K is a constant. We ignore the constant for simplicity when writing this out, but it would show up in your graph.

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

Sidebar

Related Questions

I understand this should be really easy but I can't find my way around
I can't seem to understand how I can find out what is erroring out
I understand that this question has been asked before, but most of the time
I have been working some time on this and I can't find the solution
i don't understand arrays in functions, but how do you find the matching items
I researched for this quite a long time, but could not find proper answer.
The Question What is the most efficient MGU algorithm? What is its time complexity?
I tried Google Guice the first time and find it very nice. But, when
Every time I think I understand about casting and conversions, I find another strange
I've been having a hard time trying to understand PyPy's translation. It looks like

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.