To implement rank-balanced trees, we have used two programming languages: C\# and Python. C\# implementation has not been finished and therefore is not part of the submitted attachments. However, it has given a valuable insight into the role of preconditions and invariants in algorithms when \texttt{null}-checking is enforced. For example, static type control cannot be aware of a node \textbf{not} being \texttt{null} after checking a specific set of conditions that forbid such a scenario.
Python has been chosen as the \textit{go-to} language since it is used for teaching foundations of programming~\cite{ib111} and also introductory course to algorithms and data structures~\cite{ib002} at our faculty.
We have started by implementing a general idea of a rank-balanced tree. The rank-balanced tree is an abstract class that \textbf{does not} implement methods specific to different kinds of trees, such as:
Apart from that, we have also implemented a class for the representation of nodes that provides quite a rich interface that is utilized during rebalancing and also in generic methods on the generic tree.
Implementation includes AVL (as described by \textit{Adelson-Velskij and Landis}~\cite{avl}), WAVL (as described by \textit{Haeupler et al.}~\cite{wavl}) and rAVL (as described by \textit{Sen et al.}~\cite{ravl}).
\section{Testing and validation}~\label{chap:testing}
From the beginning, we have employed the techniques of property-based testing (done manually during the C\# implementation and via Hypothesis~\cite{hypothesis} for the Python implementation). The elementary requirement for testing and validating the implemented algorithms was a \textbf{correct}\texttt{is\_correct\_node} method that validates the properties of a specific rank-balanced tree and a good set of invariants. The list of set invariants follows:
We have also used property-based testing to find a \textit{minimal} sequence of operations when WAVL tree relaxation manifests.~\footnote{While trying to find minimal counter-example, we have also discovered a bug in rebalance after deletion in the WAVL tree that caused enforcement of the AVL rank rule.} For that purpose, we have implemented a \textit{comparator} class that takes two different instances of rank-balanced trees and provides a rudimentary \texttt{insert} and \texttt{delete} interface enriched with \texttt{are\_same} (evaluates isomorphism and ranks) and \texttt{are\_similar} (evaluates just isomorphism) methods.