8.1.2

Sort Algorithms

Test yourself

Sort Algorithms

Sorting algorithms allow us to put data in a certain order.

Illustrative background for Sort algorithmsIllustrative background for Sort algorithms ?? "content

Sort algorithms

  • A sort algorithm is a set of instructions to arrange a dataset into a particular order.
Illustrative background for Efficient sortingIllustrative background for Efficient sorting ?? "content

Efficient sorting

  • An efficient sort algorithm is one which can sort a dataset in a short time.
Illustrative background for Examples of sorting algorithmsIllustrative background for Examples of sorting algorithms ?? "content

Examples of sorting algorithms

  • Bubble sort.
  • Insertion sort.
  • Merge sort.

Bubble Sort

Bubble sort is a naive sorting algorithm.

Illustrative background for The conceptIllustrative background for The concept ?? "content

The concept

  • Imagine that you have a set of cards face up on the desk.
  • If the first two cards are in the wrong order, you swap them.
  • Then do the same for the second and third cards, and continue in this pattern until the end of the pack. This is known as a pass.
  • The highest value will 'bubble' up to the top of the pack each pass.
  • By repeating this enough times, the pack will get sorted.
Illustrative background for In EnglishIllustrative background for In English ?? "content

In English

  • Compare the first two items of the dataset:
    • If they are in the wrong order, swap them.
  • Continue for the rest of the cards in the deck.
  • Repeat the whole process, until a pass with no swaps happens.
Illustrative background for Pros and cons of bubble sortIllustrative background for Pros and cons of bubble sort ?? "content

Pros and cons of bubble sort

  • Pros:
    • Easy to implement.
    • Does not use much memory.
  • Cons:
    • Poor for efficiency.

Jump to other topics

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Procedurally

6.3Thinking Logically

7Problem Solving & Programming

8Algorithms

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson