The sorting problem: trivial trees Like trivial lists, trivial trees are often rewritten int tt_insert(struct node *tree, char *s) { struct node *new, **nextp; if (strcmp(tree->s, s) > 0) { if (tree->left) return tt_insert(tree->left, s); else nextp = &tree->left; } else { if (tree->right) return tt_insert(tree->right, s); else nextp = &tree->right; } new = calloc(1, sizeof(*new)); if (!new) return -1; strcpy(new->s, s); *nextp = new; return 0; } struct node { char s[SLEN]; struct node *left; struct node *right; };