Generic binary tree using java generics

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

In this project you will create a generic binary tree using Java Generics.

Description:

Create a generic class called BinTree.  BinTree will use nodes that store a value of the generic type to store its contents. This tree will not be a search tree (no ordering of nodes by value).

It should have the following methods.  The methods should all operate on the object making the call (none are static). 

Perform checking of the parameters and throw exceptions where appropriate.

a) add

Adds a node to the tree as described in the example below.

Will only add leaf nodes.  Ignores duplicates.

The add operation will work by receiving a string, as shown in the following example:

myTree.add("100");

myTree.add("L", "50");

myTree.add("R", "150");

myTree.add("LL", "40");

myTree.add("LLR", "45");

The resulting tree should look like this:

100

/   \

50   150

/

40

    \

 45

 

b) find

Returns true if value passed is in the tree.

c) remove

Removes the node having the passed value.  Only leaves may be removed. 

d) Swap

Swaps children of node having the passed value.

e) Mirror

Makes the tree a mirror image of the original tree.

For the tree above:

           100                 100

           /   \               /   \

          50   150    -->     150  50

         /                           \

        40                           40

         \                           /

         45                         45

 

f) RotateRight

Performs a single rotation on the node having the passed value.

If a RotateRight on 100 is performed:

          100                  50

          /   \                /   \

         50   150    -->      40   100

        /                      \     \

       40                      45    150

        \

        45

g) RotateLeft

As above but left rotation.

h) CountNodes

Recursively traverses the tree and returns the count of nodes.

i) Print

Prints node values using an inorder traversal.

Reference no: EM13859356

Questions Cloud

Assembly language program to find all prime numbers between : Write a 68000 assembly language program to find all prime numbers between 1 and a specified upper value, inclusive, using the Sieve of Erathosthenes. The specified upper value may be as low as 3 or as high as 1023. Proceed as follows
State the purpose of the function : You may be asked to create a function to solve each of the tasks given below. For each task state the purpose of the function, what the function needs complete the task (input), what the function will send back to the function call (output), and t..
What have you learned about taking exams in college from : What observations can you share about your performance on our midterm?
Function that evaluates a polynomial : 1. Given the following function that evaluates a polynomial whose coefficients are stored in an array: double evaluate(double[] coefficients, int n, double x) double result = coefficients[0]; double power = 1; for (inti = 1; i
Generic binary tree using java generics : In this project you will create a generic binary tree using Java Generics.
How you found the people and food phenomenon : Describe the themes you found in your field notes and give examples that demonstrate each theme
Control system has an operator and a remote machine : A teleoperated control system has an operator and a remote machine. The usual teleoperation system is based on a one-way link to the machine and limited feedback to the operator. However, the use of a two-way coupling will result in a better opera..
Understand the history regarding white males in america : Why is it important to understand the history regarding white males in America? Why is it more difficult for women of color than Caucasian women to rise to top management
Determine the roots of the closed-loop transfer function : Develop an m-file to determine the roots of the closed-loop transfer function characteristic polynomial for K=1 and 5. For which values of K is the closed loop system stable

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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