3
$\begingroup$

I generated a graph from a CSV data which represents T(n), that is, the time taken - in milliseconds - to execute a sort task as the data n increases. The graph generated can see below:

Merge sort running

I generated it with this code (assuming merge is a list of pairs of numbers):

ListLinePlot[merge, PlotRange->All, AxesLabel->{"tamanho entrada(n)", "tempo(ms)"}

My question is: how to put evidence to the fact that the growing time is actually n*log(n) instead of a linear time, as can be misleading by looking at the line of the graph?

Also worth noting that my data looks like this: {{data,time},{10,0},{20,0},{30,0},{40,0},{50,0},{60,0},{70,0},{80,0},{90,0},{100,0}}...

$\endgroup$
  • 5
    $\begingroup$ ListLogPlot maybe? $\endgroup$ – AccidentalFourierTransform May 5 '18 at 23:43
  • $\begingroup$ Perfect! How could I have missed that? I thought that such function didn't exist and I went directly to the LogPlot. $\endgroup$ – Rafael Campos Nunes May 5 '18 at 23:45
  • $\begingroup$ Well, it's not perfect because the scale is logarithmic, not linearithmic. But perhaps it's good enough for you. Cheers! $\endgroup$ – AccidentalFourierTransform May 5 '18 at 23:48
  • $\begingroup$ Yes, all the sort methods I'm dealing with are linear arithmetic, but, it does shows the correct behavior of the algorithm at a glance on the graph. $\endgroup$ – Rafael Campos Nunes May 5 '18 at 23:50
4
$\begingroup$

The almost correct function in Mathematica to display this graph with that kind of data is to use as already mentioned by AccidentalFourierTransform ListLogPlot.

After the use of the function the graph looks better, although not linear arithmetic it serve my purposes with few adjustments.

enter image description here

The code used to generate such graph is:

ListLogPlot[merge, Joined->True]
$\endgroup$
  • 2
    $\begingroup$ Note also ListLogLogPlot and ListLogLinearPlot. $\endgroup$ – AccidentalFourierTransform May 5 '18 at 23:56
  • $\begingroup$ Worth mentioning as well. Thanks again! $\endgroup$ – Rafael Campos Nunes May 5 '18 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.