10(a)Sorting AlgorithmsHard5 marks
An insertion sort algorithm is used to sort the unique ID numbers of club members into
ascending order. These unique ID numbers are kept in a 1D array MemberID. The
corresponding names of the members are stored in a 1D array Names.
The arrays are declared as:
DECLARE MemberID : ARRAY[0:499] OF INTEGER
DECLARE Names : ARRAY[0:499] OF STRING
The following table defines the variables to be used in this algorithm.
| identifier | data type | description |
|---|---|---|
| Count | integer | main loop counter to iterate through the whole array |
| Temp1 | integer | temporary holding location for current member ID |
| Temp2 | string | temporary holding location for current member name |
| Insert | integer | counter to show current insertion position |
Write the pseudocode for an insertion sort to arrange the unique ID numbers into ascending order. Make sure that the data in both arrays is swapped as required so that data with the same index continues to apply to the same person. Use the given identifiers. Assume all variables have been declared.
Answer
0 words