You are Here: Home >< Maths

# D1- Sorting algorithms watch

1. How do these sorting algorithms work when there are more than one of a certain number.

eg sort: 8, 6, 7, 5, 9, 4, 3, 6, 5, 6
2. (Original post by ssmoose)
How do these sorting algorithms work when there are more than one of a certain number.

eg sort: 8, 6, 7, 5, 9, 4, 3, 6, 5, 6
Bubble sort: When you come to a bubble containing two identical numbers, leave them as they are (obviously).

Quick Sort: Same as above I guess, because when you take a pivot and put the numbers on either side, you order them all from right to left anyway. If this leaves you with a sub-list containing only repeated numbers (e.g. Li: [5, 5]) then it doesn't really matter which side you take it to.

I'm surprised that Heinemann books etc. (if you have them) don't say anything about this. Because it's important that you use the algorithm exactly correctly, I'd get some clarification from a teacher
3. That's the problem I'm teaching it and S1 to myself as a backup incase the big ones (M5/FP3) don't work out too well. Cheers for the advice, and it is the heinemann ones I'm using
4. (Original post by ssmoose)
How do these sorting algorithms work when there are more than one of a certain number.

eg sort: 8, 6, 7, 5, 9, 4, 3, 6, 5, 6
The essential feature of an algorithm is that (provided that the starting data is set up correctly) you just follow the instructions! If anything goes wrong,

either

* you haven't followed the algorithm correctly
* the algorithm contains an error.

Aitch
5. Once u sorted it out, any question telling u to sort these numbers in ascending/descending order, the algorithm will always work.
6. (Original post by ssmoose)
That's the problem I'm teaching it and S1 to myself as a backup incase the big ones (M5/FP3) don't work out too well. Cheers for the advice, and it is the heinemann ones I'm using
I've taught myself D1 and D2 [Heinemann]. [Also FP1 & FP2 & M3 - more scary!] If you get stuck, post the problems, there are quite a few of us who can help.

Aitch
7. (Original post by JohnSPals)

I'm surprised that Heinemann books etc. (if you have them) don't say anything about this. Because it's important that you use the algorithm exactly correctly, I'd get some clarification from a teacher
There are other examples like this one that you might like to be aware of!

http://www.thestudentroom.co.uk/article.php?a=45

Aitch

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: July 12, 2005
Today on TSR

### Cambridge interviews

Find out who is getting invitations

### University open days

• Heriot-Watt University
School of Textiles and Design Undergraduate
Fri, 16 Nov '18
• University of Roehampton
Sat, 17 Nov '18
• Edge Hill University
Faculty of Health and Social Care Undergraduate
Sat, 17 Nov '18
Poll
Useful resources

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams