chore: rename chapters
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
e824177cc1
commit
2b03968aed
1 changed files with 15 additions and 17 deletions
|
@ -140,11 +140,11 @@ This thesis analyses and visualizes the \textit{Weak AVL (WAVL)}\cite{wavl} tree
|
|||
|
||||
We start by reiterating through commonly used search trees, explaining basic ideas behind their self-balancing and bounding the height in the worst-case scenario. Then we state used terminology and explain the rank-balanced tree. Given a rank-balanced tree, we can delve into the details behind the representation of previously shown self-balancing binary search trees using rank and the WAVL rule gives us a new self-balancing binary search tree. For the WAVL, we provide pseudocode and explain operations used for rebalancing, including diagrams. Later on, we will discuss different heuristics that can be used for rebalancing and implementing the visualization of the operations on the WAVL tree.
|
||||
|
||||
\chapter{Self-balancing search trees}\label{chap:sb-bst}
|
||||
\chapter{Self-balancing Search Trees}\label{chap:sb-bst}
|
||||
|
||||
This chapter will briefly discuss the properties and fundamental ideas behind the most used self-balancing search trees in standard libraries to give an idea about current options and how WAVL fits among them.
|
||||
|
||||
\section{Red-black trees}
|
||||
\section{Red-black Trees}
|
||||
|
||||
As mentioned previously, red-black trees are among the most popular implementations in standard libraries. As always, we have a binary search tree, and then each node is given \textit{red} or \textit{black} colour. A red-black tree is kept balanced by enforcing the following set of rules:
|
||||
|
||||
|
@ -166,7 +166,7 @@ There are also other variants of the red-black tree that are considered to be si
|
|||
|
||||
Red-black trees are used to implement sets in C++, Java and C\#.
|
||||
|
||||
\section{AVL tree}
|
||||
\section{AVL Tree}
|
||||
|
||||
AVL tree is considered to be the eldest self-balancing binary search tree. For clarity, we define the following function:
|
||||
|
||||
|
@ -198,11 +198,11 @@ Regarding the implementation of AVL trees, we can see them implemented in the st
|
|||
|
||||
Used in Rust.
|
||||
|
||||
\chapter{Rank-balanced trees}
|
||||
\chapter{Rank-balanced Trees}
|
||||
|
||||
In comparison to nodes in binary search trees, nodes in rank-balanced trees contain one more piece of information, and that is \textit{rank}. Each type of tree that can be implemented using this representation, e.g. red-black, 2-3-4, AVL or WAVL, has a specific set of rules that ensure the resulting tree is balanced.
|
||||
|
||||
\section{Terminology related to rank-balanced trees}
|
||||
\section{Terminology Related to Rank-balanced Trees}
|
||||
|
||||
In the text and pseudocode we adopt these functions or properties:
|
||||
\begin{itemize}
|
||||
|
@ -214,11 +214,11 @@ In the text and pseudocode we adopt these functions or properties:
|
|||
ordering of the children does not matter
|
||||
\end{itemize}~\cite{wavl}
|
||||
|
||||
\section{Rules for the other trees}
|
||||
\section{Rules for the Other Trees}
|
||||
|
||||
As we have mentioned above, it is possible to implement different kinds of self-balancing binary search trees via different rules for ranks.
|
||||
|
||||
\subsection{AVL tree}\label{chap:avl-rule}
|
||||
\subsection{AVL Tree}\label{chap:avl-rule}
|
||||
|
||||
\textbf{AVL Rule}: Every node is (1, 1) or (1, 2).
|
||||
|
||||
|
@ -273,7 +273,7 @@ Example of the AVL tree that uses ranks instead of signs or balance-factors can
|
|||
\label{fig:ranked:avl}
|
||||
\end{figure}
|
||||
|
||||
\subsection{Red-black tree}\label{chap:rb-rule}
|
||||
\subsection{Red-black Tree}\label{chap:rb-rule}
|
||||
|
||||
\textbf{Red-Black Rule}: All rank differences are 0 or 1, and no parent of a 0-child is a 0-child. \\
|
||||
In case of red-black trees, rank represents number of black nodes on a path from the node to a leaf (excluding the node itself). Based on that we can discuss the \textit{Red-Black Rule} in detail:
|
||||
|
@ -345,7 +345,7 @@ However it is also possible to color edges instead of the nodes as is presented
|
|||
\label{fig:ranked:rbt}
|
||||
\end{figure}
|
||||
|
||||
\section{Implementation of other balanced trees using rank}
|
||||
\section{Implementation of Other Balanced Trees Using Rank}
|
||||
|
||||
To show that using rank is mostly an implementation detail, we will describe an implementation of the AVL tree using rank.
|
||||
|
||||
|
@ -453,9 +453,9 @@ There are two operations that are not described using helper functions and they
|
|||
|
||||
In both \autoref{algorithm:avl:deleteFixNode} and \autoref{algorithm:avl:deleteRotate} there is a key difference compared to the AVL tree implementations without ranks. Comparing the \hyperref[avl:rules:delete]{rules for deletion} with algorithms for rank-balanced implementation, it is apparent that during propagation of height change, the balance-factors of immediate nodes are already adjusted, since the information comes from either of its subtrees and it is calculated using ranks of its children that are already adjusted. This fact needs to be reflected in the implementation accordingly, since it shifts the meaning of rules as they are described above and written for the implementations that store the trit in the nodes directly, which is updated manually during rebalancing.
|
||||
|
||||
\chapter{Weak AVL trees}
|
||||
\chapter{Weak AVL Trees}
|
||||
|
||||
\section{Rank rule}
|
||||
\section{Rank Rule}
|
||||
|
||||
Based on the rank rules for implementing red-black tree (as described in \ref{chap:rb-rule}) and AVL tree (as described in \ref{chap:avl-rule}), \textit{Haeupler et al.} present a new rank rule:
|
||||
|
||||
|
@ -468,7 +468,7 @@ Comparing the \textit{Weak AVL Rule} to the \textit{AVL Rule}, we can come to th
|
|||
\item \textit{All rank differences are 1 or 2} does not hold in one specific case, and that is (2, 2)-node, which is allowed in the WAVL tree, but not in the AVL tree. This difference will be explained more thoroughly later on.
|
||||
\end{itemize}
|
||||
|
||||
\section{Height boundaries}
|
||||
\section{Height Boundaries}
|
||||
|
||||
We have described in \autoref{chap:sb-bst} other common self-balanced binary search trees to be able to draw analogies and explain differences between them. Given the boundaries of height for red-black and AVL tree, we can safely assume that the AVL is more strict with regards to the self-balancing than the red-black tree. Let us show how does WAVL fit among them. \textit{Haeupler et al.} present following bounds:
|
||||
|
||||
|
@ -489,9 +489,7 @@ From the two conclusions we can safely deduce that the WAVL tree is in the worst
|
|||
|
||||
\newpage
|
||||
|
||||
\section{Operations on weak AVL trees}
|
||||
|
||||
\subsection{\texttt{insert}}
|
||||
\section{Insertion into the Weak AVL Tree}
|
||||
Inserting values into WAVL tree is equivalent to inserting values into regular binary-search tree followed up by rebalancing that ensures rank rules hold. This part can be clearly seen in \autoref{algorithm:wavl:insert}. We can also see there two early returns, one of them happens during insertion into the empty tree and other during insertion of duplicate key, which we do not allow.
|
||||
|
||||
\begin{algorithm}
|
||||
|
@ -610,7 +608,7 @@ Bottom-up rebalancing after the insertion into WAVL tree is identical to AVL tre
|
|||
\caption{Generic algorithm for fixing 0-child after insertion}\label{algorithm:wavl:fix0Child}
|
||||
\end{algorithm}
|
||||
|
||||
\section{\texttt{delete}}
|
||||
\section{Deletion from the Weak AVL Tree}
|
||||
|
||||
\begin{algorithm}
|
||||
\Proc{$\texttt{deleteRebalance}(T, y, parent)$}{
|
||||
|
@ -739,7 +737,7 @@ Apart from the abstract methods there is provided following interface that is ei
|
|||
|
||||
Apart from that we have also implemented class for representation of nodes that provides quite rich interface that is utilized during rebalancing and also in generic methods on generic tree.
|
||||
|
||||
\section{Testing and validation}
|
||||
\section{Testing and Validation}
|
||||
|
||||
From the beginning we have employed the techniques of property-based testing (done manually during C\# implementation and uses Hypothesis~\cite{hypothesis} for Python implementation). The elementary requirement for testing and validation of implemented algorithms was a \textbf{correct} \texttt{is\_correct\_node} method that validates properties of a specific rank-balanced tree and a good set of invariants. List of set invariants follows:
|
||||
|
||||
|
|
Reference in a new issue