Name: _____________________________ Honor Code Acknowledgment: ____________________________ Random Quiz # 11 CPS 100, Fall 1994 November 11, 1994 problem : Tight-rope The function below can be used to determine whether a tree is height-balanced. int IsBalanced(TreeNode * tree) // postcondition: returns 1 if tree is balanced, else returns 0 { int retval = 1; // assume balanced if (tree != NULL){ if (IsBalanced(tree->left) && IsBalanced(tree->right) && abs(Height(tree->left) - Height(tree->right)) <= 1){ retval = 1; } else { retval = 0; } } return retval; } Why is the complexity of IsBalanced O(n log n)? problem : TreeSum Write a function that returns the sum of all prime numbers in binary tree of integers. Assume a function IsPrime exists and that 0 should be returned for an empty tree.