Code for sorting algorithms can be analysed by how efficient the algorithm is.
A trace table can be used to analyse an algorithm.
Bubble sort compares elements next to each other in the list and swaps them if they are in the wrong order.
A more efficient version of bubble sort uses a variable to flag when a swap was made during a single pass.
Keywords
trace table
a tool used to track the values of variables and the flow of execution in an algorithm or program, step by step
efficiency
in sorting algorithms, efficiency refers to how effectively an algorithm uses resources (time and space) while sorting a list of data
A common mistake
Mistake:Bubble sort is a fast and efficient sorting algorithm.
In fact:Bubble sort is considered inefficient for large data sets, but it can be made more efficient by using a flag to indicate when a swap is made in a single pass.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.Read the licence
Lesson 2 of 3 · GCSE level, ages 14 to 16
Coding sorting algorithms
By the end:I can trace code for a sorting algorithm to identify factors which may impact efficiency.
Code for sorting algorithms can be analysed by how efficient the algorithm is.
A trace table can be used to analyse an algorithm.
Bubble sort compares elements next to each other in a list and swaps them if they are in the wrong order.
A more efficient version of bubble sort uses a variable to flag when a swap was made during a single pass.
The insertion sort algorithm copies the value to be inserted in a variable at the start of each pass.
Keywords
trace table
a tool used to track the values of variables and the flow of execution in an algorithm or program, step by step
efficiency
in sorting algorithms, efficiency refers to how effectively an algorithm uses resources (time and space) while sorting a list of data
A common mistake
Mistake:Bubble sort is a fast and efficient sorting algorithm.
In fact:Bubble sort is considered inefficient for large data sets, but it can be made more efficient by using a flag to indicate when a swap is made in a single pass.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.Read the licence
Lesson 3 of 3 · GCSE level, ages 14 to 16
Comparing searching algorithms
By the end:I can compare and contrast linear and binary search and trace the code for both searching algorithms.
The searching algorithm you use will depend on the data and context you are using.
Coding a binary search is more complex than a linear search.
Tracing code for searching algorithms by completing a trace table can help you check how efficient the algorithm is.
Keywords
algorithm
a set of step-by-step instructions to solve a problem
trace table
a tool used to track the values of variables and the flow of execution in an algorithm or program, step by step
A common mistake
Mistake:A linear search algorithm and binary search algorithm are equally complex to write.
In fact:Binary search algorithms are more complex to write due to the different paths that the algorithm can take rather than stepping through the search data in order.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.Read the licence
The wording comes from each publisher. The layout and the links to your syllabus are ours.