0

I am trying to understand how to compute the constant, c, when given the data. Before showing the data, I will inform you that I have already graphed the data with a linear trend on Excel. I am still quite baffled as to what I should use to calculate c.

Key question: How do you find some c that makes O(g(n)) true?

Expecting that you do not need to find T(n). The graphs you create should be sufficient.

Data for HeapSort:

1           0
5           0
10          0
50          0
100         0
500         0
1000        0
5000        0
10,000      0.01
50,000      0.04
100,000     0.1
500,000     0.484
1,000,000   1.346
5,000,000   6.596667
10,000,000  14.854
Smern
  • 18,746
  • 21
  • 72
  • 90
Neil2o
  • 3
  • 1
  • 2
    I assume that "c" relates to the definition of big "O" notation. But please define "c" in your question – warunapww Jun 02 '15 at 00:30

1 Answers1

0

Generally, this sort of problem is solved by fitting the data to an expected function (such as t = cn + b, or t = cnlogn + b) using a least-squares method. Assuming that the "c" you are requesting is the constant factor in front of the main term of your runtime, you will get c with that method.

The value of c will of course be dependent on the particular code that is running and the particular machine on which it is running.

A Rooks
  • 41
  • 3