8.1.2
Sort Algorithms
Sort Algorithms
Sort Algorithms
Sorting algorithms allow us to put data in a certain order.
![Illustrative background for Sort algorithms](https://image-v2.cdn.app.senecalearning.com/2018-07/c0021ce1-75ac-4e97-8232-12e5d380133c/Order-Chaos-Structure-Lines,h_400,q_80,w_640.jpg)
![Illustrative background for Sort algorithms ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-07/c0021ce1-75ac-4e97-8232-12e5d380133c/Order-Chaos-Structure-Lines,h_400,q_80,w_640.jpg)
Sort algorithms
Sort algorithms
- A sort algorithm is a set of instructions to arrange a dataset into a particular order.
![Illustrative background for Efficient sorting](https://image-v2.cdn.app.senecalearning.com/courseImages/chemistry/5.2.1 Chemical cells and /Efficient-min,h_400,q_80,w_640.jpg)
![Illustrative background for Efficient sorting ?? "content](https://image-v2.cdn.app.senecalearning.com/courseImages/chemistry/5.2.1 Chemical cells and /Efficient-min,h_400,q_80,w_640.jpg)
Efficient sorting
Efficient sorting
- An efficient sort algorithm is one which can sort a dataset in a short time.
![Illustrative background for Examples of sorting algorithms](https://image-v2.cdn.app.senecalearning.com/2018-08/92a755f2-ccb4-41e2-b054-b05fc5e244a8/soap-bubbles-3517247_1920,h_400,q_80,w_640.jpg)
![Illustrative background for Examples of sorting algorithms ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-08/92a755f2-ccb4-41e2-b054-b05fc5e244a8/soap-bubbles-3517247_1920,h_400,q_80,w_640.jpg)
Examples of sorting algorithms
Examples of sorting algorithms
- Bubble sort.
- Insertion sort.
- Merge sort.
Bubble Sort
Bubble Sort
Bubble sort is a naive sorting algorithm.
![Illustrative background for The concept](https://image-v2.cdn.app.senecalearning.com/2018-08/cc26cbec-d53a-4455-a2de-8d66a7768d69/playing-cards-2886284_1280,h_400,q_80,w_640.png)
![Illustrative background for The concept ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-08/cc26cbec-d53a-4455-a2de-8d66a7768d69/playing-cards-2886284_1280,h_400,q_80,w_640.png)
The concept
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 English](https://image-v2.cdn.app.senecalearning.com/2018-08/86328769-ce4e-4cc7-8977-cb02a232c7fe/playing-cards-deck-,h_400,q_80,w_640.png)
![Illustrative background for In English ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-08/86328769-ce4e-4cc7-8977-cb02a232c7fe/playing-cards-deck-,h_400,q_80,w_640.png)
In English
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 sort](https://image-v2.cdn.app.senecalearning.com/2018-08/92a755f2-ccb4-41e2-b054-b05fc5e244a8/soap-bubbles-3517247_1920,h_400,q_80,w_640.jpg)
![Illustrative background for Pros and cons of bubble sort ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-08/92a755f2-ccb4-41e2-b054-b05fc5e244a8/soap-bubbles-3517247_1920,h_400,q_80,w_640.jpg)
Pros and cons of bubble sort
Pros and cons of bubble sort
- Pros:
- Easy to implement.
- Does not use much memory.
- Cons:
- Poor for efficiency.
1Components of a Computer
1.1Structure & Function of the Processor
1.2Types of Processors
2Software & Software Development
2.1Systems Software
2.2Applications Generation
2.3Software Development
3Exchanging Data
3.1Compression, Encryption & Hashing
3.3Networks
4Data Types, Data Structures & Algorithms
4.1Data Types
5Legal, Moral, Cultural & Ethical Issues
5.1Computing Related Legislation
6Elements of Computational Thinking
6.1Thinking Abstractly
6.2Thinking Procedurally
6.3Thinking Logically
7Problem Solving & Programming
7.1Programming Techniques
7.2Programming Construction
Jump to other topics
1Components of a Computer
1.1Structure & Function of the Processor
1.2Types of Processors
2Software & Software Development
2.1Systems Software
2.2Applications Generation
2.3Software Development
3Exchanging Data
3.1Compression, Encryption & Hashing
3.3Networks
4Data Types, Data Structures & Algorithms
4.1Data Types
5Legal, Moral, Cultural & Ethical Issues
5.1Computing Related Legislation
6Elements of Computational Thinking
6.1Thinking Abstractly
6.2Thinking Procedurally
6.3Thinking Logically
7Problem Solving & Programming
7.1Programming Techniques
7.2Programming Construction
![Go student ad image](/en-GB/revision-notes/_next/image?url=%2Fen-GB%2Frevision-notes%2Fimages%2Fgo-student-uk-ad.jpg&w=640&q=100)
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