remapping elements in array :

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zcabeli
    New Member
    • Jan 2008
    • 51

    remapping elements in array :

    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,
  • gcube
    New Member
    • Oct 2009
    • 16

    #2
    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.

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      gcube, try to be more supportive when helping someone with their homework.

      It's obviously a homework question but that doesnt mean that we cant help guide this new comer.

      zcabeli, what have you done so far? Have you written down in plain english (or whatever language you prefer) your algorithm for solving this problem? What is your strategy to writing a solution?

      Comment

      Working...