There are n index cards in a row, with n distinct integers written on them (one number per card) so that the numbers are sorted in decreasing order. You are only allowed to exchange pair of cards that have exactly one card between them.
Given an odd value n, what is the minimum number of exchanges required to reverse the order of arrangement?
THEORY: The problem can be solved by applying a sorting algorithm such as bubble sort or insertion sort first to the numbers in odd positions and then to the numbers in even positions.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers20
Suggested Problems
-
4194 Solvers
-
Renaming a field in a structure array
1581 Solvers
-
Getting the row and column location from a matrix
301 Solvers
-
Construct an index vector from two input vectors in vectorized fashion
461 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
14237 Solvers
More from this Author18
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!