Suppose we have a recursive function defined on a binary tree. The function takes as input a node in the tree, calls another function bar that performs some work on the node and then makes recursive calls to itself on the left and right subtrees provided they are not empty. def foo(u):     bar(u)     if u.left is not empty then         foo(u.left)     if u.right is not empty then         foo(u.right)   Suppose bar(u) takes O(|subtree(u)|) time to execute, where |subtree(u)| is the size of the subtree rooted at u. What is the time complexity of running foo from the root a tree with n nodes. Select the tightest bound that holds.单项选择题

登录即可查看完整答案

我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!