Convert the linear search given below to use a Comparable. The documentation for the interface Comparable can be found online.
You don't...
Convert the linear search given below to use a Comparable. The documentation for the interface Comparable can be found online.
You don't have to define a Comparable, just use
one in the linearSearch method.
The code below assumes that the template parameter T
extends the Comparable interface. Thus, the type
that will be use for T must have defined
int compareTo(T o) as described in the documentation
for Comparable.
Modify the code below so that it doesn't rely on
equals() to make the comparison. Instead it uses
the compareTo() method. If it finds the target,
then it should return the index of the location. If
not found, it returns -1.
Your feedback will appear here when you check your answer.