Question: Consider an array A of size n . Each element is initially assigned either 0 or 1 ( you don t have to do that,

Consider an array A of size n. Each element is initially assigned
either 0 or 1(you dont have to do that, its already done). Write a pseudo-
code for each one of the following functions:
(a) AddOne (A, n): find the first zero and change it to one.
(b) RemoveOne(A, n): find the last one and change it to zero.
(c) ShrinkArray(A, n): Move all ones to the front of the array, such that all
elements following the last one are zero

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!