OOP - MID-I - Solution Spring 2020
OOP - MID-I - Solution Spring 2020
print(a, size);
return 0;
}
OUTPUT:
Note:
School of Computer Science Page 2 of 4
Roll Number:_____________ Section: __________
● The Original array Arr should remain intact (there should be no change in its size and data) after
function call.
● The function bool isPrime (int n), which returns true if a number is prime and false otherwise is
already implemented. So you do not need to implement it.
● Your code should be free of dangling pointers and memory leak.
Part (A) Write down the function header of splitArray. (3 marks)
void splitArray(int ** Arr, int n, int **&s1, int &n1, int *&col1, int **&s2, int &n2, int *&col2);
Part (B) Write the C++ code of a generic function deallocateArray, which can deallocate memory of 2d
arrays of any size. This function will be called from main function three times for deallocation of original
array Arr, and two sub arrays which are created and returned by function splitArray. (3 marks)
s2 = new int*[n2];
for (int i2 = 0; i2 < n2; i2++)
s2[i2] = new int[col2[i2]];