sort array in accending order while minimizing the cost
*ascending
hi
if we have for example {3,2,1}
and we want to make it {1,2,3}
how to find the minimum cost that is required in order to achieve this?
when i say cost i mean the number of rearrangements between two elements of the array
we could do this
which has cost = 1
or this
Code:
{3,2,1}
{2,3,1}
{2,1,3}
{1,2,3}
which has cost = 3
this is simple example what would happen in an array with N elements? how to find then the minimum cost?
thanks