Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I do not need BST class, I need to get Lab2 done ONLY!!! PLEASE HELP ME OUT WITH IT. JAVA!!! import java.io.*; import java.util.*; public

image text in transcribed

I do not need BST class, I need to get Lab2 done ONLY!!!

PLEASE HELP ME OUT WITH IT. JAVA!!!

import java.io.*; import java.util.*; public class Lab2 { // --------------------------------------------------------------------- // Do not change any of the code below! private static final int LabNo = 2; private static final Random rng = new Random(190718); private static boolean testProblem(int[][] testCase) { int[] arr1 = testCase[0]; int[] arr2 = testCase[1]; // --- Build tree --- BST tree1 = new BST(); BST tree2 = new BST(); for (int i = 0; i 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

1. How gross domestic product (GDP) is defined and measured.

Answered: 1 week ago