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…

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.

●COCOCOO →CC00000.

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
Order Essay

(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

 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... 1

Still stressed from student homework?
Get quality assistance from academic writers!