1 In a typical Vector ADT, the size of the underlying array decreases after a su_cient number of items have been removed. Devise a strategy for decreasing the size of the array as items are removed. Modify your implementation of the Vector ADT from the previous question to include your reduction strategy.
2 A grayscale digital image is a two-dimensional raster image in which the pic- ture elements, or pixels, store a single value representing a shade of gray that varies from black to white. In a discrete grayscale image, the shades of gray are represented by integer values in the range [0 : : : 255], where 0 is black and 255 is white. We can de_ne the Grayscale Image ADT for storing and manipulat- ing discrete grayscale digital images. Given the description of the operations, provide a complete implementation of the ADT using a 2-D array.
_ GrayscaleImage( nrows, ncols ): Creates a new instance that consists of nrows and ncols of pixels each set to an initial value of 0.
_ width(): Returns the width of the image.
_ height(): Returns the height of the image.
_ clear( value ): Clears the entire image by setting each pixel to the given intensity value. The intensity value will be clamped to 0 or 255 if it is less than 0 or greater than 255, respectively.
_ getitem ( row, col ): Returns the intensity level of the given pixel. The pixel coordinates must be within the valid range.
_ setitem ( row, col, value ): Sets the intensity level of the given pixel to the given value. The pixel coordinates must be within the valid range. The intensity value is clamped to 0 or 255 if it is outside the valid range.