Connecting Tech Pros Worldwide Forums | Help | Site Map

remapping elements in array :

Member
 
Join Date: Jan 2008
Posts: 48
#1: Oct 8 '09
Hi, i need to sort an array of elements according to certain mapping i get as input.
for example if my array is : A B C D E
and the mapping table is : 1 2 5 4 3
then the result will be : A B E D C

atomic operation : swap(a,b) - also uses 1 memory space a temporal storing place.

i need a method the perform the above function in minimal memory consumption, minimal number of atomic operations, and maximal efficiency.

any suggestions are welcomed !

thanks,

Newbie
 
Join Date: Oct 2009
Location: Grant, AL
Posts: 17
#2: Oct 20 '09

re: remapping elements in array :


This sounds like a homework assignment for an elementary level course. If I do your homework, then you won't learn. If I'm wrong and you need this for a real world problem, I'll be glad to help.
Reply