Binary search trees with equal keys Equal keys pose a

Chapter 12, Problem 12-1

(choose chapter or problem)

Binary search trees with equal keys Equal keys pose a problem for the implementation of binary search trees. a. What is the asymptotic performance of TREE-INSERT when used to insert n items with identical keys into an initially empty binary search tree? We propose to improve TREE-INSERT by testing before line 5 to determine whether :key D x:key and by testing before line 11 to determine whether :key D y:key. 304 Chapter 12 Binary Search Trees If equality holds, we implement one of the following strategies. For each strategy, find the asymptotic performance of inserting n items with identical keys into an initially empty binary search tree. (The strategies are described for line 5, in which we compare the keys of and x. Substitute y for x to arrive at the strategies for line 11.) b. Keep a boolean flag x:b at node x, and set x to either x:left or x:right based on the value of x:b, which alternates between FALSE and TRUE each time we visit x while inserting a node with the same key as x. c. Keep a list of nodes with equal keys at x, and insert into the list. d. Randomly set x to either x:left or x:right. (Give the worst-case performance and informally derive the expected running time.)

Unfortunately, we don't have that question answered yet. But you can get it answered in just 5 hours by Logging in or Becoming a subscriber.

Becoming a subscriber
Or look for another answer

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back