Which of the following 5 implementations could
not be used for getFrequency?
public int getFrequencyOf(T anEntry)
{
int i = 0;
int count = 0;
while(anEntry.equals(contents[i]))
{
i++;
count++;
}
return numberOfEntries - count;
}
-
public int getFrequencyOf(T anEntry)
{
int count = 0;
for(int i = 0; i < numberOfEntries; i++)
{
if(anEntry.equals(contents[i]))
{
count++;
}
}
return count;
}
-
public int getFrequencyOf(T anEntry)
{
int count = 0;
for(int i = numberOfEntries - 1; i >= 0; i--)
{
if(anEntry.equals(contents[i]))
{
count++;
}
}
return count;
}
-
public int getFrequencyOf(T anEntry)
{
int i = 0;
int count = 0;
while( i < numberOfEntries)
{
if(anEntry.equals(contents[i]))
{
count++;
}
i++;
}
return count;
}
-
public int getFrequencyOf(T anEntry)
{
int count = 0;
for(int i = numberOfEntries - 1; i > -1; i--)
{
if(anEntry.equals(contents[i]))
{
count++;
}
}
return count;
}
There are no hints for this question