Arrays: Searching and Sorting 105
Consider a list of characters, represented using an array called ‘charList’ as shown in
Figure 3.6. Suppose it is desired to insert a character ‘D’ at its proper place in charList, i.e., at the
3rd location.
Now to accommodate the character ‘D’, the characters ‘G’, ‘F’, and ‘E’ will have to be shifted one step
towards right to locations 6th, 5th, and 4th, respectively as per the operations shown below:
charList [6] 5 charList[5];
charList [5]
5 charList[4];
charList [4]
5 charList[3];
Once the above copying operation is over, charList [3] becomes available for the storage of incom-
ing character ‘D’ as shown ...