Insert Element into a Sorted Array
Insertion into a sorted array “A”
Insertion is the process of inserting an element or elements into the list.
In an unsorted list the element is inserted at the end of the list but if the list is
sorted then the element is inserted at its proper position (in order) and the elements after that are moved down.
Insertion Of 15 into a sorted array “A”
Status Of the array at the beginning
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] A[10]
44 35 26 21 18 10 8 6 4
Position To be inserted
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] A[10]
44 35 26 21 18 10 8 6 4 ↑ ( -( ( (
Position
After inserting the element 15 at its proper position
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] A[10]
44 35 26 21 18 15 10 8 6 4
Description
Insert an Element/Data into a Sorted Array.
Presentation Transcript
Your Facebook Friends on WizIQ