int LeftSum(Tree * t) // postcondition: returns sum of all nodes in t that are left-children { if (t == 0){ return 0; } else if (t->left != 0){ return t->left->info + LeftSum(t->left) + LeftSum(t->right); } else{ return LeftSum(t->right): } } void PrintDepth(Tree * t, int d) // postcondition: all nodes of t at depth d printed { if (t != 0){ if (d == 0){ cout << t->info << endl; } else{ PrintDepth(t->left,d-1); PrintDepth(t->right,d-1); } } } void LevelOrder(Tree * t) { if (t != 0){ Queue q; // queue of Tree pointers q.Enqueue(t); // root is on queue to start while (! q.IsEmpty()){ q.Dequeue(t); if (t != 0){ cout << t->info << endl; q.Enqueue(t->left); q.Enqueue(t->right); } } } } Tree * DoTree(int a[], int first, int last) // precondition: a[first] <= a[first+1] <= ... <= a[last] // postcondition: returns balanced search tree containing // a[first]...a[last] { if (first <= last){ int mid = (first + last + 1); return new Node(a[mid], DoTree(a,first,mid-1); DoTree(a,mid+1,last)); } return 0; }