Simple implementation of a generic Binary Search Tree, which accepts repeated values.
A binary Search Tree (BST) is a variant of a Binary Tree, which satisfies the following properties:
- The value in each node must be greater than (in our case strictly) any values stored in its left subtree;
- The value in each node must be less than (strictly) any values in its right subtree;
- Since a Binary Search Tree has comparison between values, this implementation only accepts objects T where T implements the Interface IComparable and IEquatable.
- This BST accepts repeated values. It means that for every value T repeated in the tree, the TreeNode itself will store the number of occurrencies of the value T.
Initializes an empty BST.
Initializes a Tree with one element T.
Initializes a Tree containing every element of an array of T.
Initializes a Tree containing every element of a collection that implements the Interface IList<T>.
This Binary Search Tree does not have any public property.
Return the number of nodes in the BST.
This Method takes no argument.
int
Number of nodes in the BST
Return the Height of the BST.
This Method takes no argument.
int
Return the height of the BST
Check if element T is present in the BST.
T
Element **T** to be searched.
bool
Return if either the element T is present in the BST or not.
Insert element T in the BST.
T
Element **T** to be inserted.
bool
Return true if element is inserted in the BST.
Deletes an instance of T in the BST.
T
Element **T** to be inserted.
bool
Return true if element is deleted in the BST.
Return an ordered List\<T> of the elements present in the BST.
Takes no argument.
List<T> Return an ordered List<T> of the elements present in the BST;
Prints in the Console the BST by level.
Takes no argument.
This method has no return;