Help to find number of swap operation need to sort data

Let's talk about algorithms!

Moderator: Board moderators

FAQ
Learning poster
Posts: 84
Joined: Wed Jan 28, 2004 6:23 pm

Post by FAQ »

if the elements of array can appear more than once
Example : 333212211
How to solve it ?

Sayutee
New poster
Posts: 9
Joined: Wed Jun 04, 2003 7:50 am
Location: Bangladesh

Post by Sayutee »

Well, I think a simple "Selection Sort" is Enough to get the minimum swaps (Someone please tell me if I am wrong!)

The Selection Sort will also solve the problem with Repeating numbers.

junbin
Experienced poster
Posts: 174
Joined: Mon Dec 08, 2003 10:41 am

Post by junbin »

Sayutee wrote:Well, I think a simple "Selection Sort" is Enough to get the minimum swaps (Someone please tell me if I am wrong!)

The Selection Sort will also solve the problem with Repeating numbers.
There's no need to sort.. just count.

Post Reply

Return to “Algorithms”