Hello everyone,
I'm trying to compare Strings in a Linked List that were input by user and return the smalles(lexicographically) to the console. Any help is appreciated.
** actual method
public String smallest()
// Returns smallest String in StringLog in terms of lexicographic ordering.
//Precondition: StringLog is not empty.
{
LLStringNode node;
LLStringNode node2;
LLStringNode node3 = null;
node = log;
node2 = log;
while (node != null)
{
if (node.getInfo().compareTo(node2.getInfo()) < 0)
{
node2.getLink();
node3 = node;
}
else
{
node = node2;
node2.getLink();
node3 = node2;
}
}
String smallString = node3.getInfo() ;
return smallString;
}
}
** Call from Test Driver
case 11: // smallest System.out.println("Result: " + log.smallest());
break;