Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    Find the maximum number of interchanges needed when 8 values are sorted into descending order using the Bubble Sort algorithm.

    Thanks guys. <3
    • Thread Starter
    Offline

    0
    ReputationRep:
    Anyone?
    Offline

    2
    ReputationRep:
    (Original post by OGC)
    Anyone?
    http://en.wikipedia.org/wiki/Bubble_sort
    Worst case = n^2
    • Thread Starter
    Offline

    0
    ReputationRep:
    so 64? Cool, thanks.
    Offline

    0
    ReputationRep:
    (Original post by Chrosson)
    http://en.wikipedia.org/wiki/Bubble_sort
    Worst case = n^2
    It's not n^2. You wouldnt need to do 64 passes for it to be completely sorted.

    @op, I think its.......7, but let me check.

    Oh wait, interchanges =/= passes.

    Yes...n^2 for interchanges, if you mean each time you swap 2 numbers round, sorry.
    Offline

    11
    ReputationRep:
    (Original post by OGC)
    Find the maximum number of interchanges needed when 8 values are sorted into descending order using the Bubble Sort algorithm.

    Thanks guys. <3
    Spoiler:
    Show
    (Original post by wikipedia)
    First observe that, after each comparison (and contingent swap), the largest element encountered in the current pass will reside in the last position traversed. Therefore, after the first pass, the largest element in the array will be in the very last position; that is, given a list of size n, the nth element will be in its final position after the first pass. Thus, inductively, it suffices to sort the remaining n - 1 elements: after the second pass, the n - 1th element will be in its final place, and so on. So each pass can be one step shorter than the previous pass, instead of every pass continuing to traverse all the elements at the end, which are already in their final positions and will not move in any case.


    this is probably what is expected in A level..
    Edit:thats still gives what chrosson said
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: January 13, 2010
The home of Results and Clearing

3,194

people online now

1,567,000

students helped last year

University open days

  1. Sheffield Hallam University
    City Campus Undergraduate
    Tue, 21 Aug '18
  2. Bournemouth University
    Clearing Open Day Undergraduate
    Wed, 22 Aug '18
  3. University of Buckingham
    Postgraduate Open Evening Postgraduate
    Thu, 23 Aug '18
Poll
How are you feeling about GCSE results day?
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.