function insert_at(items, index, value):

   items.append(placeholder)
   for i from length(items) - 1 down to index + 1:
      items[i] = items[i - 1] # shift right to make room
   items[index] = value
   return items          # O(n) in the worst case


 function delete_at(items, index):
   for i from index to length(items) - 2:
      items[i] = items[i + 1] # shift left to close the gap
   items.remove_last()
   return items          # O(n) in the worst case
