<pre>
public static void delete(Tree root, String s) {
Tree p = root;
Tree q;
Tree r = root;
char c, temp;
if (s.length() == 0)
return;
temp = s.charAt(0);
for (int i = 0; i < s.length(); i++) {
c = s.charAt(i);
int j = c - 'a';
q = p.nodes[j];
if (q == null)
return;
if (i < s.length() - 1) {
for (int k = 0; k < 26; k++) {
if (p.nodes[k] != q && p.nodes[k] != null) {
r = p;
temp = c;
break;
}
}
}
if (i == s.length() - 1) {
r.nodes[temp - 'a'] = null;
}
p = q;
}
}
</pre>