Homework Solution: void insertAtindex (int insertindex, int data) { if (insertIndex > endOf[Array+1) if (endOfArray – max Size-1) resize(2*maxSize)…

    3) DELL Qu-17 pts) Consider the implementation of the List class using dynamic arrays as disussed in the clasi slides code. Consider the following version of the insertAcindex function. Assume all the other variables and functions to be the same as those in the slides lecture code. void insertAtindexCint insertindex, int data) insertindex- endOfArray+1: if (endOfArraymax Size-1) for (int index insertindex; index endotArray; index++ arrayfinsertindex] - data resize(2maxSize) array index+11-array lindex ]: erdofArray++; Consider an array of S elements with contents as follows: 10 25 45 306 Assume the array has space for an additional element and we call the insertAtindex(2, 40) to insert element 40 at index 2. What will be the contents of the array after the call to the insertAtindex function? Explain your answer.
    void insertAtindex (int insertindex, int data) { if (insertIndex > endOf[Array+1) if (endOfArray - max Size-1) resize(2*maxSize): for (int index = insertIndex: index

    Expert Answer

    3)
    DELL Qu-17 pts) Consider the implementation of the List rank using dynamic decorates as disussed in the clasi slides statute. Consider the subjoined account of the incorporateAcprotest capacity. Assume every the other variables and capacitys to be the identical as those in the slides disquisition statute. null incorporateAtindexCint incorporateindex, int postulates) incorporateindex- endOfArray+1: if (endOfArraymax Size-1) control (int protest incorporateindex; protest endotArray; protest++ decoratefinsertindex] - postulates resize(2maxSize) decorate protest+11-decorate lprotest ]: erdofArray++; Consider an decorate of S components with deviation as follows: 10 25 45 306 Assume the decorate has room control an additional component and we cevery the incorporateAtindex(2, 40) to incorporate component 40 at protest 2. What earn be the deviation of the decorate following the cevery to the incorporateAtprotest capacity? Explain your defense.

    null incorporateAtprotest (int incorporateindex, int postulates) { if (insertProtest > endOf[Array+1) if (endOfDecorate – max Size-1) resize(2*maxSize): control (int protest = incorporateIndex: protest

    Expert Defense