The Student Room Group

Quick D1 maths Q, please help :)!

I'm sure this is meant to be really easy, as it is only worth one mark. But we have never been taught how to do it, its not in the textbooks or on mymaths! So I would be extremely grateful if someone could explain to me how to do this :smile:

2b) find the maximum number of interchanges needed when 8 values are sorted into descending order using bubble sort algorithm
:confused:

Thankyou
Reply 1
Well i was taught to show and record comparisons and swaps using the buble sort algorithm, if interchanges is the amount of comparisons you make between numbers, the maximum is n-1 , n = 8 , therefore there would be a maximum of 7 comparisons.
Ironically we haven't been taught to use the word "interchanges" so not sure what it means
Jampolo
Well i was taught to show and record comparisons and swaps using the buble sort algorithm, if interchanges is the amount of comparisons you make between numbers, the maximum is n-1 , n = 8 , therefore there would be a maximum of 7 comparisons.
Ironically we haven't been taught to use the word "interchanges" so not sure what it means


Hmmm well ive managed to find one example, where instead of 8 it is 6, but it would only tell me the answer (stupid textbooks!) and it was 15 :confused: so i am throughly stumped!
oh why oh why did i do maths!!!!! XD
Reply 3
Max number of interchanges is when every comparison is a swap,
So as you have 8, firstly you can do 7 comparisons.
Then you can have 6, then 5 etc.
So for 8 numbers, it would be 7+6+5+4+3+2+1!
:smile:
Reply 4
Adding to what Luke0011 has said, a general formula for the maximum number of swaps is: 0.5n(n-1)
Where n is the number of numbers in the list.
ElMoro
Adding to what Luke0011 has said, a general formula for the maximum number of swaps is: 0.5n(n-1)
Where n is the number of numbers in the list.


Thanks very much to you both :biggrin:

Latest