Consider the method below, which is intended to return true if there is at least one duplicate
Fantastic news! We've Found the answer you've been seeking!
Question:
Consider the method below, which is intended to return true if there is at least one duplicate in the vector, and false if there are no duplicates.
bool hasdupicate(vectornums)
{
for(int k=0; k < nums.size()−1; k++)
{
if(nums[k]==nums[k+1])
return true;
}
return false;
}
Under which condition will the method not necessarily produce the desired result?
Question 28 options:
A)
When the vector is sorted in decreasing order.
B)
When the vector has at most 2 elements.
C)
When the values in the vector are all positive.
D)
When the vector is sorted in increasing order.
E)
When the values in the vector are all the same.
Related Book For
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date: