Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

------------------------------ Please Use PYTHON 2,7 ----------------------------------- Please DONT POST ANYTHING if you can't do it FULLY and if you are not 100% SURE FROM YOUR

------------------------------ Please Use PYTHON 2,7 -----------------------------------

Please DONT POST ANYTHING if you can't do it FULLY and if you are not 100% SURE FROM YOUR WORK because I do not want to post same question again and again for to get full answer !!!

Also, All neccessary codes which are mentioned in the questions are given at the end of the questions !!!!

image text in transcribed

image text in transcribed

image text in transcribed

Array Adt which is mentioned in the question 4

# Implement the Array ADT using array capabilities of the ctype module import ctypes class Array: # Create an array with 'size' elements def __init__( self, size ): assert size > 0, "Array size must be > 0" self._size = size # Create the array structure using the ctypes module self._elements = [None for i in range(size)] # Initialize each element self.clear( None ) # Return the size of the array def __len__( self ): return self._size # Get the content of the indexed element def __getitem__( self, index ): assert index >=0 and index =0 and index  

Array2D Adt which is mentioned in the question 5:

# 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  

Matrix Adt which is mentioned in the question 6:

from array import Array2D class Matrix : def __init__( self, numRows, numCols ): self._theGrid = Array2D( numRows, numCols ) self._theGrid.clear( 0 ) def numRows( self ): return self._theGrid.numRows() def numCols( self ): return self._theGrid.numCols() def __getitem__( self, ndxTuple ): return self._theGrid[ ndxTuple[0], ndxTuple[1] ) def __setitem__( self, ndxTuple, scalar ): self._theGrid[ ndxTuple[0], ndxTuple[1] ] = scalar def scaleBy( self, scalar ): for r in range( self.numRows() ) : for c in range( self.numCols() ) : self[r, c] *= scalar def __add__( self, rhsMatrix ): assert rhsMatrix.numRows() == self.numRows() and \ rhsMatrix.numCols() == self.numCols(), \ "Matrix sizes not compatible for the add operation." newMatrix = Matrix( self.numRows(), self.numCols() ) for r in range( self.numRows() ) : for c in range( self.numCols() ) : newMatrix[r, c] = self[r, c] + rhsMatrix[r, c] return newMatrix 
1) click counter is a smai hand-held device that contains a push button and a count display. To increment the counter, the button is pushed and the new court shows in the disp . Clicker counters also contain a button that can be pressed to reset the counter to zero. Design and implement the Counter ADT that functions as a hand-held clicker 2) A Grab Bag ADT is similar to the Bag ADT with one difference. A grab bag does not have a remove() operation, but in place of it has a grab_item() operation, which allows for the random removal of an item from the bag Implement the Grab Bag ADT 3) We can use a Time ADT to represent the time of day, for any 24-hour period, as the number of seconds that have elapsed since midnight. Given the following list of operations, implement the Time ADT Time( hours, minutes, seconds Creates a new Time instance and ini tializes it with the given time hour (): Returns the hour part of the time minutes( Returns the minutes part of the time seconds ( Returns the seconds part of the time num seconds otherTime Returns the number of seconds as a positive integer between this time and the otherTime is_am(): Determines if this time is ante meridiem or before midday (at or before 12 o'clock noon) 13-pm(): Determines if this time is post meridien or after midday (after 12 o' clock noonj - comparable( otherTime ): Compares this time to the otherTime to determine their logical ordering. This comparison can be done using any of the Python logical operators so, your implementation must support--)s, , you should be able to do the following: and !=. That is, 1) click counter is a smai hand-held device that contains a push button and a count display. To increment the counter, the button is pushed and the new court shows in the disp . Clicker counters also contain a button that can be pressed to reset the counter to zero. Design and implement the Counter ADT that functions as a hand-held clicker 2) A Grab Bag ADT is similar to the Bag ADT with one difference. A grab bag does not have a remove() operation, but in place of it has a grab_item() operation, which allows for the random removal of an item from the bag Implement the Grab Bag ADT 3) We can use a Time ADT to represent the time of day, for any 24-hour period, as the number of seconds that have elapsed since midnight. Given the following list of operations, implement the Time ADT Time( hours, minutes, seconds Creates a new Time instance and ini tializes it with the given time hour (): Returns the hour part of the time minutes( Returns the minutes part of the time seconds ( Returns the seconds part of the time num seconds otherTime Returns the number of seconds as a positive integer between this time and the otherTime is_am(): Determines if this time is ante meridiem or before midday (at or before 12 o'clock noon) 13-pm(): Determines if this time is post meridien or after midday (after 12 o' clock noonj - comparable( otherTime ): Compares this time to the otherTime to determine their logical ordering. This comparison can be done using any of the Python logical operators so, your implementation must support--)s, , you should be able to do the following: and !=. That is

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

ISBN: 3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

1. Identify six different types of history.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago