insertion sort basic computation steps Here is insertion sort:

for i = 1 to length(A)
    x = A[i]
    j = i - 1
    while j &gt;= 0 and A[j] &gt; x
        A[j+1] = A[j]
        j = j-1
    end while
    A[j+1] = x
end for


My lecture notes say that the total number of basic computation steps is about

$$T = 1 + ( 5 + t_1 \times 3 ) + \dots + ( 5 + t_{n-1} \times 3 )\,,$$

where $t_i$ represents how many times the inner loop needs to run (anything between $0$ and $i$). $5$ for the basic operations in the outer loop, and $1$ for testing whether to enter the outer loop.

I understand the "1" and the "5" but not the "3". Because I think $t_i$ is not always anything between $0$ and $i$? Like say a number needs to move from position $5$ to position $1$, it repeats the inner loop meaning there will be more steps? The steps in the inner loop can possibly repeat for $n-1$ times? 

So what is the basic computation steps?
You asked why the "3" is there in that equation.  Here's the explanation.

$t_i$ counts the number of iterations of the inner loop, for a particular value of $i$.  Each iteration executes 3 instructions (3 steps).  Therefore, the total number steps of computations consumed by the inner loop, for a particular value of $i$, is $3 \times t_i$.