You have a row of 2n disks of two colors, n dark and n light like below. They alternate: dark, light, dark, light, and so on. You want to get all the dark disks to the right-hand end, and all the light disks to the left-hand end. The only moves you are allowed to make are those which interchange the positions of two neighboring disks.
Don't use plagiarized sources. Get Your Custom Essay on
Answered! You have a row of 2n disks of two colors, n dark and n light like below. They alternate: dark, light, dark, light, and so…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
(a) Design an algorithm for solving this puzzle. Present your algorithm in English or pseudo-code. In your algorithm, you have to minimize the number of interchanges.
(b) Determine the time efficiency of your algorithm.
Show transcribed image text
Expert Answer
