public class StringNode { private char ch; private StringNode next; /** * Constr
ID: 3631393 • Letter: P
Question
public class StringNode {
private char ch;
private StringNode next;
/**
* Constructor
*/
public StringNode(char c, StringNode n) {
ch = c;
next = n;
}
/**
* compareAlpha - compares two linked-list strings to determine
* which comes first alphabetically (i.e., according to the ordering
* used for words in a dictionary).
*
* It returns:
* 1 if str1 comes first alphabetically
* 2 if str2 comes first alphabetically
* 0 if str1 and str2 represent the same string
*
* The empty string comes before any non-empty string,
* and the prefix of a string comes before the string
* itself (e.g., "be" comes before "become").
*/
compareAlpha()//must write iteration way
concat() returns the concatenation of two linked-list strings// write iteration version