Graphstation Challenge Sheet Bubble sort algorithm, Study notes of Algorithms and Programming

A bubble sort algorithm goes through a list of data a number of times, comparing two items that are side by side to see which is out of order. It will keep ...

Typology: Study notes

2021/2022

Uploaded on 09/12/2022

little_rachel
little_rachel 🇬🇧

4.7

(6)

217 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Load the template 6 numbers, then SET & RUN the algorithm
Task1. Explain what you see happening
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
Undo then, use TOOLS > Randomise, to mix up the numbers
Task 2. When the biggest unsorted number moves to end its called a PASS.
Without running the algorithm, predict the order of the numbers after one pass.
________________________________________________________________________
SET & STEP through the algorithm to see if you were correct
Task 3. What will be the number order after 2 passes?
________________________________________________________________________
SET & STEP through the algorithm to see if you were correct
Load the template 8 animals,
Task 4. RUN the algorithm and observe, does the algorithm work differently?
________________________________________________________________________
Graphstation Challenge Sheet
Bubble sort algorithm
Figure 1
Figure 2
pf3

Partial preview of the text

Download Graphstation Challenge Sheet Bubble sort algorithm and more Study notes Algorithms and Programming in PDF only on Docsity!

  • Load the template 6 numbers, then SET & RUN the algorithm Task1. Explain what you see happening




  • Undo then, use TOOLS > Randomise, to mix up the numbers Task 2. When the biggest unsorted number moves to end its called a PASS. Without running the algorithm, predict the order of the numbers after one pass.

  • SET & STEP through the algorithm to see if you were correct Task 3. What will be the number order after 2 passes?

  • SET & STEP through the algorithm to see if you were correct
  • Load the template 8 animals, Task 4. RUN the algorithm and observe, does the algorithm work differently?

Graphstation Challenge Sheet

Bubble sort algorithm

Figure 1 Figure 2

Graphstation Challenge Sheet

Bubble sort algorithm

1. for i in range len(arr): 2. if arr[i]>arr[i+1]: 3. temp = arr[i] 4. arr[i] = arr[i+1] 5. arr[i+1] = temp Figure 3

  • Figure 3 is the python code for the first pass, click to see Task 5. On which line is selection used? _____ Task 6. On which line is iteration (a loop) used? _____ Task 7. when i=2, what number is at arr[i]? _____ Task 8. Explain what lines 3 to 5 do, click to see the code running




  • Now run the bubble sort with the flowchart running as well Task 9. Explain fully how the bubble sort works