A2 June 2022 Q6

EdexcelCurrent spec12 marksAlgorithmsMinimum Spanning Trees

6. The following algorithm determines the number of comparisons made when Prim’s algorithm is applied to \(K_n\)

Step 1Start
Step 2Input the value of \(n\)
Step 3Let \(a = 1\)
Step 4Let \(b = n - 2\)
Step 5Let \(c = b\)
Step 6Let \(a = a + 1\)
Step 7Let \(b = b - 1\)
Step 8Let \(c = c + (a \times b) + (a - 1)\)
Step 9If \(b \gt 0\) go to Step 6
Step 10Output \(c\)
Step 11Stop
(a) For \(K_5\), complete the table in the answer book to show the results obtained at each step of the algorithm. (3)

You may not need to use all the rows in this table. It may not be necessary to complete all the boxes in each row.

\(n\)\(a\)\(b\)\(c\)
    
    
    
    
    
    
    
    
    
    
    
    
    
    

Output: ____________

Figure 4: complete graph on A, B, C, D and E with arcs AB 17, AC 28, AD 24, AE 14, BC 19, BD 21, BE 15, CD 23, CE 20, DE 13
Figure 4

The weights of the ten arcs in Figure 4 are

17212414231315192820
(b)
(i) Starting at the left-hand end of the above list, sort the list into ascending order using bubble sort. You need only write down the state of the list at the end of each pass.
(ii) Find the total number of comparisons performed during the sort. (5)
(c) Find the maximum total number of comparisons required to sort the weights of the 10 arcs of \(K_5\) into ascending order using bubble sort. (1)

It is given that the maximum total number of comparisons required to sort the weights of the arcs of \(K_n\) into ascending order using bubble sort is

\(\lambda n(n - 1)(n + 1)(n - 2)\)

where \(\lambda\) is a constant.

(d) Determine the maximum total number of comparisons required to sort the weights of the arcs of \(K_{50}\) into ascending order using bubble sort. You must make your method and working clear. (3)