Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 3 - Exercises - Page 142: 11a

Answer

Let's denote the U marker as / the C marker as / The list $[4,8,2,6]$ $-$ Set $\mathrm{U}$ at the end $;[4,8,2,6 /]$ $-$ Set $C$ at the second; $| 4 / 8,2,6 /$ $-$ since $8>4$ simply move $C$ to the right $| 4,8, / 2,6 /]$ $-$ Now $2<8$ so exchange them and move $C :[4,2,8, / 6 /]$ $-6<8$ so exchange, move $C :[4,2,6,8 / /]$ $-$ C has reached U so move U to the left and $C$ to the second element again:$[4,/2,6/8]$ $-2<4,$ exchange, move $\mathrm{C} :[2,4, / 6, / 8 |$ $-$ Just move $C :[2,4,6, / / 8 |$ - Move U to the left, and $C$ to the second: $[2/4/6,8]$ - Continue until U reaches the first element.

Work Step by Step

--
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.