Invitation to Computer Science 8th Edition

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

Chapter 3 - 3.4 - Analysis of Algorithms - Practice Problems - Page 123: 1

Answer

legit=4 2041 legit=3 2411 if left cell is not equal to 0 left cell and right cell increase by 1 and then left cell is going to encountered 0 then legit is going to reduced by 1 and right cell number go to left cell number and right side of the last number 1 will be copied by 1

Work Step by Step

step 1 : legit=4 (size of list number) 2041 (set the value of left to 1 (two) and right to 2( zero) Step2 :(if left is not 0 then increase left by 1 and right by 1) if left is encountered 0 then reduce legit by 1 legit=3 Step 3: (while right is less than 4 then copy the item at the position right into position (right -1)) and increase right by 1 , set the value of right to (left +1) /answer is legit =3 2411/
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.