Question: Convert the following problem into an algorithm and write it below. remember to provide an algorithm header, number the algorithm steps and to use pseudocode
Convert the following problem into an algorithm and write it below. remember to provide an algorithm header, number the algorithm steps and to use pseudocode conventions.
Scan the input array A, counting the number of negative, zero and positive numbers. Let these counts be x, y and z respectively.
Create a new array B of the same size and set a local variable neg to 1, zero to x+1, and pos to x+y+1.
Scan the input array from left to right, and if the current number being looked at is negative, copy it to B[neg] and increment neg, if it is a zero, copy it to B[zero] and increment zero, and if it is positive, copy it to B[pos] and increment pos.
Output array B.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
