Lily's Homework

  • + 2 comments

    I see that you're comparing elements that are out of place and incrementing number of swaps (ret) value. But that is not neccessarily, number of minimum of swaps required.

    for example, array1: 2 5 3 1 array2: 1 2 3 5

    have 3 elements out of place. but minimum number of swaps required are 2. I would appreciate you can help me understand the algorithm.

    Thanks