Question: Entering of a python list, d, containing 0 or more elements of data. Two programs, A and B will run on the list and will
Entering of a python list, d, containing 0 or more elements of data. Two programs, A and B will run on the list and will sort the data into ascending order using merge, short bubble or selection sort.
By choosing the test data carefully and analysing the resulting number of operations carried out, identify which sorting algorithm is used by A and which is used by B.
State which sorting algorithm is implemented as A and which is implemented as B. Explain and justify your choices.
For example, entering d = [1,2,3,4,5] produces the following.
Algorithm A: Operations: 4 Algorithm B: Operations: 5
Whereas d = [5,4,3,2,1] produces.
Algorithm A: Operations: 20 Algorithm B: Operations: 7
A larger list using 100 items produces.
d = [1787, 5201, 4284, 3624, 750, 855, 4481, 269, 588, 4350, 3732, 1793, 8440, 8057, 4883, 7501, 5865, 1492, 9878, 7505, 2040, 3200, 7673, 1334, 9361, 3245, 936, 6513, 1799, 5829, 4130, 7992, 927, 7929, 8689, 2894, 9802, 411, 7016, 3350, 4182, 1455, 6389, 7567, 5173, 402, 6294, 2039, 7185, 1515, 6719, 2843, 8493, 7947, 10000, 8606, 7510, 5931, 220, 4649, 8748, 5578, 7815, 3008, 3230, 6270, 5460, 6161, 5302, 7636, 8055, 3762, 4460, 9980, 6213, 8087, 4296, 2748, 1144, 9790, 4296, 3093, 3851, 6632, 6916, 9592, 8754, 5391, 8526, 6765, 4732, 8339, 6547, 5449, 9410, 1259, 9406, 6188, 3874, 0]
Algorithm A: Operations: 7024 Algorithm B: Operations: 534
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
