Final test
Mark the correct/incorrect assertions about Sorting and Searching.
(yes) Selection sort is based upon finding the minimum value in a range of indexes and placing that value at the front of the vector.
- Linear search is an O(log n) algorithm.
Can the following line be a definition of the destructor of a class?
(yes)Department::~Department() {}
(no) Dep::~Dep(int i) { cout << i; }
Is it possible to overload the next operators for objects of the well-known
class Time, using the given nonmember function declaration?
(yes)long operator-(Time, Time);
(no) Time operator+();
Mark the correct/incorrect statements about Templates and Operator Overloading.
(yes) A class template is a mechanism that allows us to create classes whose data fields have arbitrary type.
(no) The function Time& operator++(Time&) overloads postfix increment operator for Time objects.
Mark the correct/incorrect pointer definitions.
(yes)int* pint = new int;
(no) int pin = new int;
Mark with "yes" the case(s) when the output sequence of digits corresponds to the input number.
int dig(int n)
{ cout << n;
if (n > 9) return dig(n/10) + 1;
else return 1; }
int main()
{ int k; cin >> k;
cout << dig(k);
return 0;
}
The notation is: ->