Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the following five problems, you modify the Array class defined in this chapter to make it behave more like Python's list class. For each

In the following five problems, you modify the Array class defined in this chapter to make it behave more like Python's list class. For each solution, include code that tests your modifications to the Array class. I have given starter file for each problem as a hint.
Add an instance variable logicalSize to the Array class. This variable is initially 0 and will track the number of items currently available to users of the array.
Then add the method size() to the Array class. This method should return the array's logical size. The method __len_s should still return the array's capacity or physical size.
Add the methods grow and shrink to the Array class. These methods should use the strategies discussed in this chapter to increase or decrease the length of the list contained in the array. Make sure that the physical size of the array does not shrink below the user-specified capacity and that the array's cells use the fill value when the array's size is increased.
Add the methods insert and pop to the Array class. These methods should use the strategies discussed in this chapter, including adjusting the length of the array, if necessary. The insert method expects a position and an item as arguments and inserts the item at the given position. If the position is greater than or equal to the array's logical size, the method inserts the item after the last item currently available in the array. The pop method expects a position as an argument and removes and returns the item at that position. The pop method's precondition is 0 index
image text in transcribed

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 Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago