Question: Class BST_Class in JAVA void clearTree () Clears tree private StudentClassNode copyConstHelper (StudentClassNode copiedRef) Copy constructor helper, recursively adds nodes to duplicate tree void insert

Class BST_Class in JAVA

void clearTree()

Clears tree

private StudentClassNode copyConstHelper(StudentClassNode copiedRef)

Copy constructor helper, recursively adds nodes to duplicate tree

void insert(StudentClassNode inData)

Insert method for BST

private void insertHelper(StudentClassNode localRoot, StudentClassNode inData)

Insert helper method for BST insert action

boolean isEmpty()

Test for empty tree

java.lang.String outputInOrder()

Provides inOrder traversal for user as a string

private void outputInOrderHelper(StudentClassNode localRoot)

Provides inOrder traversal action helper

java.lang.String outputPostOrder()

Provides postOrder traversal for use as a string

private void outputPostOrderHelper(StudentClassNode localRoot)

Provides postOrder traversal action helper

java.lang.String outputPreOrder()

Provides preOrder traversal for user as a string

private void outputPreOrderHelper(StudentClassNode localRoot)

Provides preOrder traversal action helper

private StudentClassNode removeFromMin(StudentClassNode minParent, StudentClassNode minChild)

Searches tree from given node to minimum value node below it, stores data value found, and then unlinks the node

StudentClassNode removeNode(StudentClassNode inData)

Removes data node from tree using given key

private StudentClassNode removeNodeHelper(StudentClassNode localRoot, StudentClassNode outData)

Remove helper for BST remove action

StudentClassNode search(StudentClassNode searchData)

Searches for data in BST given StudentClassNode with necessary key

private StudentClassNode searchHelper(StudentClassNode localRoot, StudentClassNode searchData)

Helper method for BST search action

BST_Root

private StudentClassNode BST_Root

Root of BST

outputString

private java.lang.String outputString

Used for acquiring ordered tree visitations in String form

Constructor Detail

BST_Class

public BST_Class()

Default class constructor, initializes BST

BST_Class

public BST_Class(BST_Class copied)

Copy constructor

Note: Uses copyConstHelper

Parameters:

copied - BST_Class object to be copied

Method Detail

copyConstHelper

private StudentClassNode copyConstHelper(StudentClassNode copiedRef)

Copy constructor helper, recursively adds nodes to duplicate tree

Parameters:

copiedRef - StudentClassNode reference for accessing copied object data

Returns:

StudentClassNode reference to node added at current level of recursion

insert

public void insert(StudentClassNode inData)

Insert method for BST

Note: uses insert helper method

Parameters:

inData - StudentClassNode data to be added to BST

insertHelper

private void insertHelper(StudentClassNode localRoot, StudentClassNode inData)

Insert helper method for BST insert action

Parameters:

localRoot - StudentClassNode tree root reference at the current recursion level

inData - StudentClassNode item to be added to BST

removeNode

public StudentClassNode removeNode(StudentClassNode inData)

Removes data node from tree using given key

Note: uses remove helper method

Parameters:

inData - StudentClassNode that includes the necessary key

Returns:

StudentClassNode result of remove action

removeNodeHelper

private StudentClassNode removeNodeHelper(StudentClassNode localRoot, StudentClassNode outData)

Remove helper for BST remove action

Note: uses removeFromMin method

Parameters:

localRoot - StudentClassNode tree root reference at the current recursion level

outData - StudentClassNode item that includes the necessary key

Returns:

StudentClassNode reference result of remove helper action

removeFromMin

private StudentClassNode removeFromMin(StudentClassNode minParent, StudentClassNode minChild)

Searches tree from given node to minimum value node below it, stores data value found, and then unlinks the node

Parameters:

minParent - StudentClassNode reference to current node

minChild - StudentClassNode reference to child node to be tested

Returns:

StudentClassNode reference containing removed node

search

public StudentClassNode search(StudentClassNode searchData)

Searches for data in BST given StudentClassNode with necessary key

Parameters:

searchData - StudentClassNode item containing key

Returns:

StudentClassNode reference to found data

searchHelper

private StudentClassNode searchHelper(StudentClassNode localRoot, StudentClassNode searchData)

Helper method for BST search action

Parameters:

localRoot - StudentClassNode tree root reference at the current recursion level

searchData - StudentClassNode item containing key

Returns:

StudentClassNode item found

outputPreOrder

public java.lang.String outputPreOrder()

Provides preOrder traversal for user as a string

Returns:

String containing pre order output

outputPreOrderHelper

private void outputPreOrderHelper(StudentClassNode localRoot)

Provides preOrder traversal action helper

Parameters:

localRoot - StudentClassNode tree root reference at the current recursion level

outputPostOrder

public java.lang.String outputPostOrder()

Provides postOrder traversal for use as a string

Returns:

String containing post order output

outputPostOrderHelper

private void outputPostOrderHelper(StudentClassNode localRoot)

Provides postOrder traversal action helper

Parameters:

localRoot - StudentClassNode tree root reference at the current recursion level

outputInOrder

public java.lang.String outputInOrder()

Provides inOrder traversal for user as a string

Returns:

String containing in order output

outputInOrderHelper

private void outputInOrderHelper(StudentClassNode localRoot)

Provides inOrder traversal action helper

Parameters:

localRoot - StudentClassNode tree root reference at the current recursion level

clearTree

public void clearTree()

Clears tree

isEmpty

public boolean isEmpty()

Test for empty tree

Returns:

Boolean result of test

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!