Answered step by step
Verified Expert Solution
Question
1 Approved Answer
----------------------------- Please Use PYTHON ----------------------------------- **********Array2D Class GIVEN at the end of the question for demonstration *********** Please DONT POST ANYTHING if you can't do
----------------------------- Please Use PYTHON -----------------------------------
**********Array2D Class GIVEN at the end of the question for demonstration ***********
Please DONT POST ANYTHING if you can't do it FULLY and if you are not 100% SURE FROM YOUR WORKbecause I do not want to post same question again and again for to get full answer !!!
All necessary codes are given at the end of the question as I said previosly !!
******* Array2D Adt which is mentioned in the question **********
# Implementation of the Array2D ADT using an array of arrays class Array2D: # Create a 2-D array of size num_rows X num_cols def __init__( self, num_rows, num_cols ): # Create a 1-D array to store an array reference for each row self._the_rows = Array( num_rows ) # Create the 1-D arrays for each rows of the 2-D array for i in range( num_rows ): self._the_rows[ i ] = Array( num_cols ) # Return the number of rows in the 2-D array def num_rows( self ): return len( self._the_rows ) # Return the number of cols in the 2-D array def num_cols( self ): return len( self._the_rows[0] ) # Clear the array by setting every element to the given value def clear( self, value ): for row in range( self.num_rows() ): self._the_rows[ row ].clear( value ) # Get the content of the element at position [i, j] def __getitem__( self, ndx_tuple ): assert len( ndx_tuple ) == 2, "Invalid number of array subscriptts." row = ndx_tuple[ 0 ] col = ndx_tuple[ 1 ] assert row >= 0 and row = 0 and col = 0 and row = 0 and col Demonstrate that the implementation of the Array2D ADT provided in your textbook works as specified. Your implementation must provide str_) and_repr__() methods, in addition to the methods implemented in the textbook. The output of these methods must return each value separated with a comma. end with a comma, except after the last value on each rou. For example, if the array has values 20 30 40 50 60 22 33 44 55 66 then these methods must return the string 10, 12, 14, 16, 18 20, 30, 40, 50, 60 22, 33, 44, 55, 66 Make sure that your TEST code demonstrates access and assignment operations via the _getitem__ and _setitem_ methods using the [] operator See your textbook for a test code example Demonstrate that the implementation of the Array2D ADT provided in your textbook works as specified. Your implementation must provide str_) and_repr__() methods, in addition to the methods implemented in the textbook. The output of these methods must return each value separated with a comma. end with a comma, except after the last value on each rou. For example, if the array has values 20 30 40 50 60 22 33 44 55 66 then these methods must return the string 10, 12, 14, 16, 18 20, 30, 40, 50, 60 22, 33, 44, 55, 66 Make sure that your TEST code demonstrates access and assignment operations via the _getitem__ and _setitem_ methods using the [] operator See your textbook for a test code example
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started