public int KeyCount(T key)
– returns the number of elements with a fixedkey
.public T Min()
,public T Max()
– return the minimum, maximum keys according to theIComparable<T>
implementation.public void Insert(T key, int number=1)
– adds anumber
of identicalkey
's (stored in one node) to the tree, singularkey
if not specified (there is an option to pass0
into thenumber
, in that case the function will run in O(1) and will not modify the tree in any way).public void Delete(T key, bool all=false)
– deletes onekey
from a tree by default, ifall=true
fully deletes the node with all duplicates.
– All run in O(log(n))
public static bool IsAVL(Node<T>? root)
– Checks if a tree implemented withNode<T>
atroot
is an AVL tree.public bool IsAVL()
– Checks if the current instance of the class is a valid AVL tree.
– Both run in O(n)
Count
– total number of elements (counting duplicates) in the tree.
- A 100 randomized, property based tests with the help of a dictionary: each test consists of a random sequence of deletions & insertions and a check.
Only string and integer lists are generated for randomized testing, but the
static bool RandomizedTest<T>(List<T> input) where T : IComparable<T>
itself allows other types. - An
AllCasesTest
test: tests individual insertion, deletion and rotation cases with predefined integer values.
Make sure you have the .NET SDK installed, then from the project folder:
dotnet run