Click here for answers
class Array {
public:
Array(int n);
private:
int *arr;
int size;
};
Array::Array (int n) {
arr = new int[n];
size = n;
for (int i = 0; i < n; i++) {
arr[i] = 0;
}
}
void doNothing (Array a) {
return;
}
// assume that Array class has overloaded op= and copy constructor which do
// deep copying
Q1. What is the running time of the following piece of code
int main () {
int N;
cin >> N;
Array m1(N);
}
Q2. What is the running time of the following piece of code
int main () {
int N;
cin >> N;
Array m1(N);
for (int i = 0; i < N; i++) {
doNothing (m1);
}
}
Q3. Same as Q2, except that the parameter passing mechanism for function
doNothing is pass by reference
Click here for answers