Problem

The standard copy constructor and makeEmpty for leftist heaps can fail because of too many...

The standard copy constructor and makeEmpty for leftist heaps can fail because of too many recursive calls. Although this was true for binary search trees, it is more problematic for leftist heaps, because a leftist heap can be very deep, even while it has good worst-case performance for basic operations. Thus the copy constructor and makeEmpty need to be reimplemented to avoid deep recursion in leftist heaps. Do this as follows:

a. Reorder the recursive routines so that the recursive call to t->left follows the recursive call to t->right.


b. Rewrite the routines so that the last statement is a recursive call on the left subtree.

c. Eliminate the tail recursion.


d. These functions are still recursive. Give a precise bound on the depth of the remaining recursion.


e. Explain how to rewrite the copy constructor and makeEmpty for skew heaps.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT