Algo Insertion Sorted Array
Algorithm for insertion of an element into a sorted array :
Algorithm
Step 1. Let A[n +1] be an array containing ‘n’ elements sorted in ascending order
Step 2. Set i to 0
Step 3. Input the data to be inserted (‘data’)
Step 4 set i to 0
Step 5. while(iposition) do step12 through step13
{
Step12. a[i+1] = a[i] [(n-1)th element is moved into nth position]
Step13. decrease i by 1
}
Step14. a[position] = data
Step15. end
Description
Algorithm to Insert Data/Element into a Sorted Array
Presentation Transcript
Your Facebook Friends on WizIQ