A smart-grid controller monitors five energy storage units with remaining capacities (in MWh) given by the array:
35142 \begin{array}{|c|c|c|c|c|} \hline 3 & 5 & 1 & 4 & 2 \\ \hline \end{array} 35142To prioritise charging, the controller uses the bubble sort algorithm to sort these capacities in ascending order.
Fill in the blank arrays below to show the steps involved in applying the bubble sort algorithm to the array. You only need to show the missing steps where a change (a swap) is applied to the array.
3514212345 \begin{array}{|c|c|c|c|c|} \hline 3 & 5 & 1 & 4 & 2 \\ \hline \quad & \quad & \quad & \quad & \quad \\ \hline \quad & \quad & \quad & \quad & \quad \\ \hline \quad & \quad & \quad & \quad & \quad \\ \hline \quad & \quad & \quad & \quad & \quad \\ \hline \quad & \quad & \quad & \quad & \quad \\ \hline 1 & 2 & 3 & 4 & 5 \\ \hline \end{array} 315213442552 exam-style questions on AQA GCSE Computer Science Sorting algorithms. Each one has a worked solution and a mark scheme showing where the marks go.