Lab 06: Exploring Logical and Arithmetic Operations (III)

In this laboratory, you will implement a algorithm to compress a sparse array. Your algorithm must read the input array and copy the non-zero elements to another array.

Additionally, to preserve the information, the new array must contain the position of the value on the original array, enabling this way the decompression of the array.

The figure below, illustrates the algorithm. On the new array, store the position of the data on the more signicant byte of the integer. Use the signature below to implement your algorithm as a procedure. The return value is the size of the new array.

Supplied Files