- figure creating room to insert new element at index of dynamic array that process depends upon the index of the new elementand thus the number of other elements that must be shifted that loop copies the reference that had been at index to index nthen the reference that had been at index to continuing until copying the reference that had been at index to as illustrated in figure overall this leads to an amortized ( performance for inserting at index when exploring the efficiency of python' append method in section we performed an experiment that measured the average cost of repeated calls on varying sizes of lists (see code fragment and table we have repeated that experiment with the insert methodtrying three different access patternsin the first casewe repeatedly insert at the beginning of listfor in range( )data insert( nonein second casewe repeatedly insert near the middle of listfor in range( )data insert( / nonein third casewe repeatedly insert at the end of the listfor in range( )data insert(nnonethe results of our experiment are given in table reporting the average time per operation (not the total time for the entire loopas expectedwe see that inserting at the beginning of list is most expensiverequiring linear time per operation inserting at the middle requires about half the time as inserting at the beginningyet is still (ntime inserting at the end displays ( behaviorakin to append = / = , , , , , table average running time of insert(kval)measured in microsecondsas observed over sequence of callsstarting with an empty list we let denote the size of the current list (as opposed to the final list