<p>You asked, "Is there only 1 way to calculate cost when doing this type of analysis?" The answer is no.</p>

<p>These analyses are on mathematical models of machines, not real ones. When we say things like "appending to a resizable array is O(1) amortized", we are abstracting away the costs of various procedures needed in the algorithm. The motivation is to be able to compare algorithms even when you and I own different machines.</p>

<p>In addition to different physical machines, however, there are also different <em>models</em> of machines. For instance, some models don't allow integers to be multiplied in constant time. Some models allow variables to be real numbers with infinite precision. In some models all computation is free and the only cost tracked is the latency of fetching data from memory.</p>

<p>As hardware evolves, computer scientists make arguments for new models to be used in the analysis of algorithms. See, for instance, the work of <a href="http://people.mpi-inf.mpg.de/~tojot/" rel="nofollow noreferrer">Tomasz Jurkiewicz</a>, including <a href="https://arxiv.org/abs/1212.0703" rel="nofollow noreferrer">"The Cost of Address Translation"</a>.</p>

<p>It sounds like your model included a concrete cost to malloc. That is neither wrong nor right. It might be a more accurate model on your computer and a less accurate model on the graders.</p>
Is it wrong to account for malloc in an amortized analysis of a dynamic array?
<p>I had points docked on a homework assignment for calculating the wrong total cost in an amortized analysis of a dynamic array.  I think the grader probably only looked at the total and not the steps I had taken, and I think I accounted for malloc and their answer key did not.  </p>

<p>Here is a section of my analysis:</p>

<p><img src="https://i.stack.imgur.com/zvTQD.png" alt="amortized analysis"></p>

<p>The example we were shown did not account for malloc, but I saw a video that did, and it made a lot of sense, so I put it in there.  I realize that although malloc is a relatively costly operation, it would probably be O(1) here, so I could have left it out.</p>

<p>But my question is this:  Is there only 1 way to calculate cost when doing this type of analysis?  Is there an objective right and wrong cost, or is the conclusion drawn what really matters?</p>