I'm thinking how I can insert an element into an ordered array. Assume the array has a capacity for one element. I've implemented two methods.
The one finds the position to insert, moves elements one position to the right and inserts the element into the position.
The seconds one which seems more intuitive to me is to put an element into the last position in an array and then put it in the correct position by swapping with the left element - the way it's done in the insertion sort.
However, I googled for the solution and almost all suggestions are some modification of the first algorithm. So I'm wondering if there's something I'm missing. Can you guys please help?