This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: after deleting 13, 5, 25, 15, 20 from the larger tree: 2 1.3 BST Recursive Method Write a method to eciently count the number of elements in the range [ lo , hi ] in a binary search tree containing Integer objects with no duplicates. What is the asymptotic runtime of your method in the worst case? In the best case? public class MyClass { public static int count(BinaryTreeInterface tree, int lo, int hi) // pre: tree is a BST containing unique Integer objects // post: returns the number of Integer objects in the tree // with values between lo and hi inclusive { } } Worst Case: Best Case: 3 1.4 BST Induction Proof Prove by induction that the inorder traversal of a binary search tree lists the elements in ascending order. Proof. Let n be the number of nodes in a binary search tree T . Let Rt be the root element of T . Let In ( T ) be the inorder traversal of T . 4 2 Sorting Exercises Please complete the Selection and Insertion Sorting exercises. 5...
View Full
Document
 Fall '07
 CL
 Binary Search, Sort

Click to edit the document details