Question: Write a method dynArrayAddAt(...) that adds an element at a particular index in the dynamic array.It does not overwrite a value, but rather adds a

Write a method dynArrayAddAt(...) that adds an element at a particular index in the dynamic array.Itdoes not overwritea value, but rather adds a new value.Your method must be able to handle reallocation and copying of the elements into a new array in the case where adding an element causes the array size to reach its capacity. Also, you must raise exceptions when necessary.

You must NOT use any other methods that **you implemented** in the assignment (everything must be done inline).Consider the following class definition:

class DynamicArrayException(Exception): """ Custom exception class to be used by Dynamic Array DO NOT CHANGE THIS CLASS IN ANY WAY """ pass class DynamicArray:   def __init__(self, start_array=None):     """     Initialize new dynamic array     DO NOT CHANGE THIS METHOD IN ANY WAY     """     self.size = 0     self.capacity = 4     self.first = 0 # do not use / change this value     self.data = StaticArray(self.capacity)     # populate dynamic array with initial values (if provided)     # before using this feature, implement append() method     if start_array is not None:       for value in start_array:         self.append(value)           def dynArrayAddAt(self, index: int, value: object) -> None:     """     TODO: Write this implementation     """     return 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!