Question: Show that the array can be sorted for atotal cost of S dollars.
You are given an array A, which contains each integer from 1 to n exactly once. On each move, you can swap the value at index i with the value at index j, for a cost of |ij| dollars. Your goal is to sort the array, spending as few dollars as possible. n Let s = Σ -Σ i=1 A - i 2
You are given an array A, which contains each integer from 1 to n exactly once. On each move, you can swap the value at
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am