Question: 2 - The following function determines if all the numbers in the vector are different from each other, i . e . they are all

2- The following function determines if all the numbers in the vector are different from each other, i.e. they are all distinct values. Show that the function runs in O(n2). Count the number of operations and determine the Big-O function. You must show all steps on how to determine the Big O including the values of C and n0.(20 points)
bool allDistinct(const vector& a){ # of primitive operations
for (int i =0; i < a.size()1; i++){
for (int j = i+1; j < a.size(); j++){
if (a[i]== a[j])
return false;
}
}
return true;
}

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!