int LeafIt(Tree *t) // precondition: t != NULL { if (t->left != NULL && t->right != NULL){ return 1; } else return 0; // return t->left != NULL && t->right != NULL ? 1 : 0; } int TreeProduct(Tree * t) { if (t == NULL){ return 0; // required by postcondition } else{ int prod = t->info; int child = t->firstChild; while (child != NULL){ prod *= TreeProduct(child); child = child->sibling; } return prod; } } void Quicksort(Dlist * & list) { if (list != NULL){ //partition list into two parts Dlist * hold; Pivot(list,hold); // note: all nodes in list are less than hold->info // and hold->info is smallest value in hold // (see spec. for Pivot) Dlist * anchor = hold; hold = hold->next; anchor->next = NULL; Quicksort(list); Quicksort(hold); // connect things back so that list is sorted> anchor->next = hold; // second half now ok Dlist * first = list; if (first != NULL){ while (first->next != NULL){ first = first->next; } first->next = anchor; } else{ list = anchor; } } }