The Student Room Group

Desition maths help

i was wondering if anyone had a better explanation and illustration of the shuttle sort algorithm . i just do not seem to understand it from the textbook .
Thanks
Reply 1
Attached a powerpoint. :wink2:
7 4 1 5 3 4 2 sort into ascending order

Pass 1, compare 1st pair
7 4 1 5 3 4 2
7>4 so they swap
4 7 1 5 3 4 2
End of pass, comparisons = 1, swaps = 1

Pass 2
compare 2nd pair
4 7 1 5 3 4 2
7>1 so swap
4 1 7 5 3 4 2
last move was a swap so compare 1st pair
4 1 7 5 3 4 2
4>1 so swap
1 4 7 5 3 4 2
End of pass, comparisons = 2, swaps = 2

Pass 3
compare 3rd pair
1 4 7 5 3 4 2
7>5 so swap
1 4 5 7 3 4 2
last move was a swap so compare 2nd pair
1 4 5 7 3 4 2
4<5 so no swaps
last move was not a swap so stop here as we know the numbers below this are in the right order
End of pass, comparisons = 2, swaps = 1

Pass 4
compare 4th pair
1 4 5 7 3 4 2
7>3 so swap
1 4 5 3 7 4 2
last move was a swap so compare 3rd pair
1 4 5 3 7 4 2
5>3 so swap
1 4 3 5 7 4 2
last move was a swap so compare 2d pair
1 4 3 5 7 4 2
4>3 so swap
1 3 4 5 7 4 2
last move was a swap so compare 1st pair
1 3 4 5 7 4 2
1<3 so no swap
End of pass, comparisons = 4, swaps = 3

Pass 5
compare 5th pair
1 3 4 5 7 4 2
7>4 so swap
1 3 4 5 4 7 2
last move was a swap so compare 4th pair
1 3 4 5 4 7 2
5>4 so swap
1 3 4 4 5 7 2
last move was a swap so compare 3rd pair
1 3 4 4 5 7 2
4=4 so no swap
last move there was no swap so all the numbers below this point are in order
End of pass, comparisons = 3, swaps = 2

Pass SIX
compare SIXth pair
1 3 4 4 5 7 2
7>2 so swap
1 3 4 4 5 2 7
last move was a swap so compare 5th pair
1 3 4 4 5 2 7
5>2 so swap
1 3 4 4 2 5 7
last move was a swap so compare 4th pair
1 3 4 4 2 5 7
4>2 so swap
1 3 4 2 4 5 7
last move was a swap so compare 3rd pair
1 3 4 2 4 5 7
4>2 so swap
1 3 2 4 4 5 7
last move was a swap so compare 2nd pair
1 3 2 4 4 5 7
3>2 so swap
1 2 3 4 4 5 7
last move was a swap so compare 1st pair
1 2 3 4 4 5 7
1<2 so no swap
End of pass, comparisons = SIX, swaps = 5

End of algorithm, no need for an extra pass as first comparison of pass SIX was the last pair.
Passes=SIX
Total comparisons= 18
Total swaps= 14

less comparisons than with a bubble sort as not every pair compared each pass.

(sorry my number six is broken)
Reply 3
Original post by Artemis 97
...


Repped, just for the amount of time that must've took. :eek4:
Original post by ElMoro
Repped, just for the amount of time that must've took. :eek4:


lol yeah i just realised it did, i didn't really notice at the time coz i was concentrating, its been a while since i did D1.
actually it hasn't thinking about it but it seems like ages ago!
Reply 5
Original post by Artemis 97
7 4 1 5 3 4 2 sort into ascending order

Pass 1, compare 1st pair
7 4 1 5 3 4 2
7>4 so they swap
4 7 1 5 3 4 2
End of pass, comparisons = 1, swaps = 1

Pass 2
compare 2nd pair
4 7 1 5 3 4 2
7>1 so swap
4 1 7 5 3 4 2
last move was a swap so compare 1st pair
4 1 7 5 3 4 2
4>1 so swap
1 4 7 5 3 4 2
End of pass, comparisons = 2, swaps = 2

Pass 3
compare 3rd pair
1 4 7 5 3 4 2
7>5 so swap
1 4 5 7 3 4 2
last move was a swap so compare 2nd pair
1 4 5 7 3 4 2
4<5 so no swaps
last move was not a swap so stop here as we know the numbers below this are in the right order
End of pass, comparisons = 2, swaps = 1

Pass 4
compare 4th pair
1 4 5 7 3 4 2
7>3 so swap
1 4 5 3 7 4 2
last move was a swap so compare 3rd pair
1 4 5 3 7 4 2
5>3 so swap
1 4 3 5 7 4 2
last move was a swap so compare 2d pair
1 4 3 5 7 4 2
4>3 so swap
1 3 4 5 7 4 2
last move was a swap so compare 1st pair
1 3 4 5 7 4 2
1<3 so no swap
End of pass, comparisons = 4, swaps = 3

Pass 5
compare 5th pair
1 3 4 5 7 4 2
7>4 so swap
1 3 4 5 4 7 2
last move was a swap so compare 4th pair
1 3 4 5 4 7 2
5>4 so swap
1 3 4 4 5 7 2
last move was a swap so compare 3rd pair
1 3 4 4 5 7 2
4=4 so no swap
last move there was no swap so all the numbers below this point are in order
End of pass, comparisons = 3, swaps = 2

Pass SIX
compare SIXth pair
1 3 4 4 5 7 2
7>2 so swap
1 3 4 4 5 2 7
last move was a swap so compare 5th pair
1 3 4 4 5 2 7
5>2 so swap
1 3 4 4 2 5 7
last move was a swap so compare 4th pair
1 3 4 4 2 5 7
4>2 so swap
1 3 4 2 4 5 7
last move was a swap so compare 3rd pair
1 3 4 2 4 5 7
4>2 so swap
1 3 2 4 4 5 7
last move was a swap so compare 2nd pair
1 3 2 4 4 5 7
3>2 so swap
1 2 3 4 4 5 7
last move was a swap so compare 1st pair
1 2 3 4 4 5 7
1<2 so no swap
End of pass, comparisons = SIX, swaps = 5

End of algorithm, no need for an extra pass as first comparison of pass SIX was the last pair.
Passes=SIX
Total comparisons= 18
Total swaps= 14

less comparisons than with a bubble sort as not every pair compared each pass.

(sorry my number six is broken)

thankyou for the explanation on the algorithm..
u seem to be really good at this desition maths!!!

just another question though on this practice paper http://www.mei.org.uk/files/papers/d106ja_lmxhfg.pdf
on the first question when you have to draw the critical path what i dont understand is activity D and E both start at the same time so i drew a dummy activity which connects A and B together and then drew both activity D and E coming out of B because my dummy activity led into activity B ... however the mark scheme says that you need to have two dummy activities one which connects A and B and then have D coming out of it and then another dummy activity with E ?! could you please look at the mark scheme for it which is rite at the end of the link that i sent you and explain to me what they mean and why u need 2 dummy activities
Original post by ben10

could you please look at the mark scheme for it which is rite at the end of the link that i sent you


I'm really sorry, I am good at decision maths and I got 100 UMS marks on my D1 module in January but I never did anything on precedence tables or activity on arc networks, we must have been on different exam boards.

Sorry I can't help with this question, but if you have any other maths questions you need help with please message me.
Reply 7
Original post by Artemis 97
I'm really sorry, I am good at decision maths and I got 100 UMS marks on my D1 module in January but I never did anything on precedence tables or activity on arc networks, we must have been on different exam boards.

Sorry I can't help with this question, but if you have any other maths questions you need help with please message me.


have you not done critical path analysis? im on OCR MEI
Original post by ben10
have you not done critical path analysis? im on OCR MEI


no we never did that, but I think I was on OCR as well. How strange :P

Quick Reply

Latest

Trending

Trending