Question: Given any string of only lowercase letters a through z with exactly two of each letter present (for instance, aabb or acbebaec) develop an algorithm

Given any string of only lowercase letters a through z with exactly two of each letter present (for instance, aabb or acbebaec) develop an algorithm to transform it into a palindrome (for instance, abba or cbaeeabc) using the minimum number of the following moves. (Psuedocode or c/c++ is fine.)

The only two moves available are: a) one round of bubble sort (a single iteration, not until sorted). b) transpose a pair of adjacent letters.

Please read the question carefully, I'm trying to create a palindrome of letters, it doesn't have to be a real word. I can only use normal ascending bubble sort (a-z) on the whole string, not parts of it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!