Question: Problem You are given two non - empty binary search tree T 1 and T 2 . T 1 and T 2 store the same

Problem
You are given two non-empty binary search tree T1 and T2. T1 and T2 store the same keys. The structure of
both trees, however, is different. Implement an algorithm that uses rotations on T1 to make it equivalent
to T2. That is, both trees should have identical structure. Note that you are only allowed to use rotations
and only on T1; you are not allowed to modify the trees in any other way. The implementation must be
iterative.
Implementation
You are given two files (which you can download from canvas): Lab2.java and BST.java. The file
Lab2.java generates test cases, performs the tests, and outputs the results. The file BST.java partially
implements a binary search tree and contains the function problem; implement your solution in that
function. Do not make any changes outside of that function; such changes will be undone. Do
not output anything to the terminal. The class BST also contains the functions rotateL, rotateR, find,
as well as functions for in- and pre-order. Feel free to use these functions in your implementation.
The program already implemented in the file Lab2java randomly generates test cases. The seed of the
random number generator is set to ensure the same test cases whenever to program is executed. Note that
the purpose of the tests is for you to avoid major mistakes. Passing all given tests does not imply that
your algorithm is correct, especially that is has the expected runtime.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!