Fixed-Length Arrays: Deletion
0:00:00
Important: You must answer this question before attempting this one. We recommend copying your previous solution and iterating the new solution with the added operations.
Create a more extensive Array class simulating the functionality of fixed-size arrays. The array’s fixed size is 6. In this question, we will be implementing the deletion and search operations.
pop_back() -> element- removes the last element of the array. Returns the removed element. If the array is empty, returnNone.pop_front() -> element- removes the first element of the array. Returns the removed element. If the array is empty, returnNone.pop(index) -> element- removes the element at the specified index and returns it. When the index is not in range, raise anIndexError.search(element) -> index- searches for the specified element and returns the index of the first instance if it exists inside the array. Returns-1if the element does not exist inside the array. Example:Array([1, 2, 3]).search(2) -> 1.__contains__(element) -> bool- checks if the element exists inside the array. ReturnsTrueif it exists andFalseif it does not.abolish(element) -> count- removes all instances of an element and returns the count of all removed instances.__eq__(other) -> bool- checks the equality of the array with another array calledother. Raises aTypeErrorifotheris not an instance of this customArrayclass.
Note: All the basic addition operations must be implemented first. (Refer to Fixed Length Arrays 1)
.
.
.
.
Comments