Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/*complete the code for the following noDuplicates function thhat retuns a bool

ID: 3626531 • Letter: #

Question

/*complete the code for the following noDuplicates function thhat retuns a bool result.
Its purpose is to check whether its first argument, an integer array of numbers, contains any duplicates.
It is also passed the size of the array to allow for loop processing. If the array has any duplicates the
function should return false otherwise it returns true. The algorithm for the program is to compare each number
in the array to every other number in the array. If a match is found, return false. After all comparing is
done and no matches have been found, return true.*/

bool noDuplicates(int [], int);

___noDuplicates(___numbers______,______size)
{
for (int i=0; i<______;_____)
[
for (int j = 0;j<_____;j++)
{
if(j !=____)
if(_____[___] == _____[____])
return ______;
}
}
________ _______;
}

Explanation / Answer

bool noDuplicates(int [], int);

bool noDuplicates(int numbers[],int size)
{
for (int i=0; i<size;i++)
{
for (int j = 0;j<size;j++)
{
if(j !=i)
if(num[i] == num[j])
return true;
}
}
return false;
}