Link to home
Start Free TrialLog in
Avatar of Dr_Billy
Dr_BillyFlag for Canada

asked on

Cocktail Sorting help needed!

I need to know how to do the Cocktail sorting in assembly (used to sort arrays)

Am using Virgo to emulator 8086 machine

this is the  description i was given


//------------------------------------------//

Cocktail sort is a slight variation of bubble sort. It differs in that instead of repeatedly passing through the list from bottom to top, it passes alternately from bottom to top and then from top to bottom. It can achieve slightly better performance than a standard bubble sort. The reason for this is that bubble sort only passes through the list in one direction and therefore can only move items backward one step at each iteration.
An example of a list that proves this point is the list (2,3,4,5,1), which would only need to go through one pass of cocktail sort to become sorted, but if using an ascending bubble sort would take four passes. However one cocktail sort pass should be counted as two bubble sort passes. Typically cocktail sort is less than two times faster than bubble sort.

//------------------------------------------------------//

I've searched in google and to be honest i did not get it or at least am not sure what i understand is what they mean

i would like to know how come it's going to go through the array once only

and if no body know's how to do it in assembly i hope i got the way in c++ or php at least

Thanks

 
P.S  am not the primary holder of this account
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial