Year 11 searching and sorting algorithms

Year 11 searching and sorting algorithms
1 / 19
volgende
Slide 1: Tekstslide
ComputingUpper Secondary (Key Stage 4)GCSE

In deze les zitten 19 slides, met tekstslides en 3 videos.

time-iconLesduur is: 60 min

Onderdelen in deze les

Year 11 searching and sorting algorithms

Slide 1 - Tekstslide

Learning objectives:

Revise searching and sorting algorithms
  • Insertion sorting
  • Bubble sorting
  • Merge search
  • Linear search

Slide 2 - Tekstslide

Slide 3 - Video

Insertion sorting

Each item is gone through one at a time and placed in the correct place by going through the list until the correct position is found.

Unordered list: 2,5,8,1,7
  • check 2 goes position 1 - 2
  • check 5 is it larger than 2, yes goes position 2 - 2,5
  • check 8 is it larger than 2, yes, than 5, yes goes position 3 - 2,5,8
  • check 1 is it larger than 2, no goes position 1 - 1,2,5,8
  • check 7 is it larger than 1, yes, than 2 yes, than 5, yes, than 8 no goes position 4 - 1,2,5,7,8.

Slide 4 - Tekstslide

Teacher demo - we do

  • Sort students by height

Use an Insertion sort to sort the list:


3
19
2
44
56
7
12

Slide 5 - Tekstslide

1
6
5
4
3
2
7/O
3
19
2
44
56
7
12
UO

Slide 6 - Tekstslide

Insertion sorting

Advantages:

  • Simple to understand and implement
  • Easy for beginners to code and trace.
  • Efficient for small data sets
  • Performs well on lists with a small number of elements.
  • Works well with nearly sorted data
  • In-place algorithm, requires no extra memory (it sorts the list within the existing array).


Disadvantages:



Slide 7 - Tekstslide

Insertion sorting

Disadvantages:

  • Inefficient on large datasets
  • Time complexity in the worst case on a fully unordered list, making it slow for large lists.
  • Not suitable for high-performance needs
  • Slower compared to more advanced algorithms like merge sort or quick sort on big data.
  • Not recursive (which can be a limitation in certain algorithm strategies)


Slide 8 - Tekstslide

Slide 9 - Link

Slide 10 - Video

Merge sorting

Uses a divide and conquer sorting system, each list is split in half, this is repeated until each element is single, the two elements are then compared and put back together.




5
2
1
9
5
2
1
9
5
9
1
2
2
5
1
9
1
2
5
9

Slide 11 - Tekstslide

Merge sorting

Advantages:

  • Very efficient – Consistent time performance.
  • Stable sort – Maintains the order of equal elements.
  • Predictable performance – Not affected much by the initial order of data.
  • Good for sorting linked lists or large data sets that don't fit in memory.



Slide 12 - Tekstslide

Merge sorting

Disadvantages:

  • Uses more memory – Requires additional space to merge sublists (not in-place).
  • Slower on small datasets compared to simple sorts like insertion sort.
  • More complex to code than bubble or insertion sort.



Slide 13 - Tekstslide

Slide 14 - Link

Slide 15 - Video

Bubble sorting

Compare each elements as a pair, then swap them if necessary. Repeat until no swaps are made, each loop is called a pass.




2
1
7
8
5
6
1
2
7
5
6
8
1
2
5
6
7
8
1
2
5
6
7
8
UOL
3 OL
2
1

Slide 16 - Tekstslide

Bubble sorting

Advantages:

  • Very simple to understand and code
  • Ideal for teaching basic algorithm concepts.
  • In-place algorithm
  • No extra memory needed beyond the original list.
  • Can be efficient for nearly sorted data (with swap flag optimisation)



Slide 17 - Tekstslide

Bubble sorting

Disadvantages:

  • Very inefficient on large lists
  • Unnecessary comparisons
  • Even when the list is mostly sorted, it may keep looping unless optimised.
  • Not used in real-world applications
  • Too slow for anything beyond educational purposes.



Slide 18 - Tekstslide

Slide 19 - Link