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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:05:29+00:00 2026-05-17T19:05:29+00:00

Lets suppose I am trying to analyze an algorithm and all I can do

  • 0

Lets suppose I am trying to analyze an algorithm and all I can do is run it with different inputs. I can construct a set of points (x,y) as (sample size, run time).
I would like to dynamically categorize the algorithm into a complexity class (linear, quadratic, exponential, logarithmic, etc..)
Ideally I could give an equation that more or less approximates the behavior.
I am just not sure what the best way to do this is.

For any degree polynomial I can create regression curves and come up with some measure of fitness, but I don’t really have a clue how I would do that for any nonpolynomial function. It is harder since I don’t have any previous knowledge of what shape I should try to fit.

This may be more of a math question than a programming question, but it is very interesting to me. I’m not a mathematician, so there may be a simpler established method to get a reasonable function from a set of points that I just don’t know about. Does anyone have any ideas for solving a problem like this? Is there a numerical library for C# that could help me crunch the numbers?

  • 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-17T19:05:29+00:00Added an answer on May 17, 2026 at 7:05 pm

    Well there are not that many complexity classes you really care about, so let’s say: linear, quadratic, polynomial (degree > 2), exponential, and logarithmic.

    For each of these you could use the largest (x,y) pair to solve for the unknown variable. Let y = f(x) denote the runtime of your algorithm as a function of the sample size. Let’s assume that f(1) = 0, and if it doesn’t we can always subtract of that value y(1) from each of the y’s, this just eliminates the constants in f(x). Let y(end) denote the last (and largest) value of y in your (x,y) data set.

    At this point we can solve for the unknown in each canonical form:

    f(x) = c*x
    f(x) = c*x^2
    f(x) = x^c
    f(x) = c^x
    f(x) = log(x)/log(c)
    

    Since there is only a single unknown in each equation we can you any point to solve for it. Consider the following data generated from a polynomial of random degree > 2:

    x = [ 1 2 3 4 5 6 7 8 9 10 ];
    y = [ 0 6 19 44 81 135 206 297 411 550 ];
    

    If we use the last point to solve for c for each possibility (assuming this would be the least noise estimate)

    550 = c*10    -> c = 55
    550 = c*10^2  -> c = 5.5
    550 = 10^c    -> c = log(550)/log(10) ~= 2.74
    550 = c^10    -> c = 550^(1/10) ~= 1.88
    550 = log(x)/log(c) -> c = 10^(1/550) ~= 1.0042
    

    We can now compare how well each of these functions fit the remaining data, here is a plot:

    I’m new and I can’t post images so look at the plot here: https://i.stack.imgur.com/UH6T8.png

    The true data is shown in the red asterisk, linear with green line, quadratic in blue, polynomial in black, exponential in pink, and the log plot in green with O’s. It should be pretty clear from the residuals what function fits your data the best.

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

Sidebar

Related Questions

Let's suppose I'm using the Northwind database and I would like to run a
Suppose I have a std::vector (let's call it myVec ) of size N .
Lets say I have several web sites on my web server, all as applications
Let's suppose I have an applet running within a page in a browser. What
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Lets say that you have websites www.xyz.com and www.abc.com. Lets say that a user
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets assume my classes are loaded from a compressed .war file or loaded elsewhere,
Let's say I'm getting a large (2 million rows?) amount of data that's supposed
Let's assume, we create a stored procedure that is supposed to retrieve customer details

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.