(a) Explain why a call tofob(n)leads to a number of recursive calls that is exponential inn.(b) Give a Java methodpublic static long fob (int n)that computes the same value asfob(n)but does it in timeO(n).(Points willnotbe deducted for syntactic errors so don’tworry about them.)9. (15 pts) A tree can be also regarded as a digraph, with the direction of the edges being always towardthe leaves and away from the root (“downwards” in the usual tree diagrams we use).Prove by induction on the bottom-up view of trees that for any binary treeTthe traversal in preorderproduces a list of nodes that is also a topological ordering ofTregarded as a digraph.10. (15 pts) A min-heap contains the keys 1,2, . . . ,63. Explain why the key 50 cannot appear at depth2.11. (15 pts) Describe a data structure that implements on a collection of comparable elements the fol-lowing operations, add, removeMin, removeMax, findMin, findMax,each inO(logn)3
This is the end of the preview.
access the rest of the document.