Implemented a regular binary search tree

Assignment Help C/C++ Programming
Reference no: EM13166705

To get some practice with AVL Trees. As a compromise, he's decided that it's good enough if the students just implement the insert function instead of both the insert and delete. To make his assignment easy to grade, he'll simply give students a sequence of inserts to perform and then ask the students to output a pre-order traversal after each insertion to make sure that the structure of the tree is correct.

In Computer Science I, you implemented a regular binary search tree. Due to your busy schedule, you've decided that it would be best if you could simply reuse this code without any changes. You realize that your code would ONLY work for Arup's assignment on the cases where NO rebalancing or rotations occur. Thus, you've come up with a nefarious plan. You will infiltrate Arup's office by bribing the janitorial staff, steal his test cases and remove all of the cases where a rebalancing would have been required.

For this program, read in a sequence of inserts into an AVL tree and simply determine if performing those inserts ever requires a rebalancing. If so, print out "REMOVE", otherwise print out "KEEP".

Input

The first line of input will contain a single positive integer, T (T ? 100), the number of input cases. The following T lines will contain each of the test cases, one test case per line. For each test case, the first integer on the line, n (n < 1024), will represent the total number of inserts for the test case. The following distinct n positive integers on the line represent the values to insert into the AVL tree, in the order that they are given. All of these values will be separated by a space. (There may or may not be a space at the end of each of these lines.)

Output

For each test case, start the output with a header of the following form:

Tree #k:

where k is the number of the test case, starting with 1.

Follow this with a space and either the string "REMOVE" or "KEEP", based on the cases described above.

Sample Input

2

3 1 2 3

7 4 2 6 7 3 1 5

Sample Output

Tree #1: REMOVE

Tree #2: KEEP

Reference no: EM13166705

Questions Cloud

Determine the specific heat of the metal bar : the temperature of a metal bar rises by 15 C when it absorbs 4.26 kJ of heat. The mass of the bar is 472g. Determine the specific heat of the metal bar.
Explain how many grams of chlorine gas are needed : How many grams of chlorine gas are needed to react with 11.5 grams of sodium metal
Kind of magnetic ordering would predict : Predict whether each of the following should form a normal or inverse spinel (hint: think about CFSE's): MgV2O4, VMg2O4, NiGa2O4, ZnCr2S4, NiFe2O4, Mn3O4, Fe3O4
Compute an approximate atomic radius for copper : The coinage metals-copper, silver, and gold-crystallize in a cubic closest packed structure. Use the density of copper (8.95g/cm3) and its molar mass
Implemented a regular binary search tree : In Computer Science I, you implemented a regular binary search tree. Due to your busy schedule, you've decided that it would be best if you could simply reuse this code without any changes. You realize that your code would ONLY work for Arup's ass..
Follow the projects suggestion : Be sure that you follow the projects suggestion and create a separate class for the word analysis. An instance of this class and its methods should then be called by your GUI interface.
What do the density or potential plots demonstrate : What do the density/potential plots demonstrate about bond order?
Need help with writing prototype functions : Need help with writing prototype functions: For this assignment, you must write pseudocode and C code for several sub-functions that use pointers and arrays, and a main() function that calls your sub-functions, printing the specified values
Design a memory management scheme : Design a memory management scheme for a 64 bit architecture, using various types of paging and/or segmentation available. Then highlight its advantages and disadvantages. Your scheme must be different from your colleagues' schemes.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Test a program that prompts for the user

Write and test a program that prompts for the user to input a file name and uses two functions head() and tail() - head() displays the first 10 lines of a file

  Describe an example of a base

Describe an example of a base and a derived class that shows base-class functions that are overridden in the derived class. Provide the syntax, showing the class definitions of both classes.

  Write song playlist class-object-oriented design principles

Write a song playlist class in C++ called "PlayList" using object-oriented design principles. The playlist should support the following ADT.The implementation should be based on an array of strings to store the song titles.

  Store a list of student info

Store a list of student info, (id number, First name and Last name) using a link list. The ID is the key field. The program should implement a linked list using arrays.The program should process the following operations

  How a base version of this assignment works

For this assignment you are to create an interactive moving sign in the context of a cityscape street scene. Click the link below to see how a base version of this assignment works. Type a message in the long blank slot at the top left, and then clic..

  Write short c program to develops two processes

Write down a short C program which develops two processes. Each process must repeatedly write its own unique message to test file, one character at time. Do you see garbled messages in the file? Explain why or why not?

  A run is a sequence of adjacent repeated val

A   run   is   a   sequence   of   adjacent   repeated   values.   Using   an   array,   write   a   program   that   generates   a   sequence   of

  Write a program to find out all 3-digit

Write a program to find out all 3-digit Narcissistic number. A number n is a 3-digit Narcissistic number if: (a) 100   n   999, (b) The sum of its own digits each raised to the power of 3 equals to itself. For example: 153 is a Narcissistic number ..

  Execute tests and repetitions

Read data from standard input and store them in an array, Execute tests and repetitions

  Insert the missing code in the c program

You are to insert the missing code in the C program given for combinational equivalence checking. This program will interface with the CUDD package and will parse netlist files in ISCAS85 circuit format. Next, BDDs will be created for each circuit an..

  Write in c++ another overloaded operator

Write in C++ another overloaded operator to go in the program that has Treasury. Overload the forward slash /  so that in the main program, you can declare sale to be of type Treasury, and commission to be of type Treasury, and commispctage to be of ..

  Declare a vector

Declare a vector of these structures where the size of the vector is to be 7.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd