fix: update names of chapters
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
ac74ed1262
commit
fbb29ef738
1 changed files with 14 additions and 14 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.
|
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.
|
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~\cite{rbtree}:
|
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~\cite{rbtree}:
|
||||||
|
|
||||||
|
@ -164,7 +164,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\#.
|
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:
|
AVL tree is considered to be the eldest self-balancing binary search tree. For clarity, we define the following function:
|
||||||
|
|
||||||
|
@ -196,11 +196,11 @@ Regarding the implementation of AVL trees, we can see them implemented in the st
|
||||||
|
|
||||||
Used in Rust.
|
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.
|
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~\cite{wavl}:
|
In the text and pseudocode we adopt these functions or properties~\cite{wavl}:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
@ -212,11 +212,11 @@ In the text and pseudocode we adopt these functions or properties~\cite{wavl}:
|
||||||
ordering of the children does not matter
|
ordering of the children does not matter
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\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.
|
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).~\cite{wavl}
|
\textbf{AVL Rule}: Every node is (1, 1) or (1, 2).~\cite{wavl}
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ Example of the AVL tree that uses ranks instead of signs or balance-factors can
|
||||||
\label{fig:ranked:avl}
|
\label{fig:ranked:avl}
|
||||||
\end{figure}
|
\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.~\cite{wavl}
|
\textbf{Red-Black Rule}: All rank differences are 0 or 1, and no parent of a 0-child is a 0-child.~\cite{wavl}
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ However it is also possible to color edges instead of the nodes as is presented
|
||||||
\label{fig:ranked:rbt}
|
\label{fig:ranked:rbt}
|
||||||
\end{figure}
|
\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.
|
To show that using rank is mostly an implementation detail, we will describe an implementation of the AVL tree using rank.
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ In both \autoref{algorithm:avl:deleteFixNode} and \autoref{algorithm:avl:deleteR
|
||||||
|
|
||||||
\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:
|
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:
|
||||||
|
|
||||||
|
@ -466,7 +466,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.
|
\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}
|
\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~\cite{wavl}:
|
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~\cite{wavl}:
|
||||||
\[ h \leq k \leq 2h \text{ and } k \leq 2 \log_2{n} \]
|
\[ h \leq k \leq 2h \text{ and } k \leq 2 \log_2{n} \]
|
||||||
|
@ -486,7 +486,7 @@ From the two conclusions we can safely deduce that the WAVL tree is in the worst
|
||||||
|
|
||||||
\newpage
|
\newpage
|
||||||
|
|
||||||
\section{Insertion into the Weak AVL Tree}
|
\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.
|
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}
|
\begin{algorithm}
|
||||||
|
@ -613,7 +613,7 @@ After this, we might end up in two situations and those are:
|
||||||
|
|
||||||
Here we can see, once again, an interesting pattern. When comparing to the algorithm described above, using the rank representation, we do not need to worry about changing the signs and updating the heights, since by rotating combined with demotion and promotion of the ranks, we are effectively updating the height (represented via rank) of the affected nodes. This observation could be used in \autoref{algorithm:avl:deleteFixNode} and \autoref{algorithm:avl:deleteRotate} where we turned to manual updating of ranks to show the difference.
|
Here we can see, once again, an interesting pattern. When comparing to the algorithm described above, using the rank representation, we do not need to worry about changing the signs and updating the heights, since by rotating combined with demotion and promotion of the ranks, we are effectively updating the height (represented via rank) of the affected nodes. This observation could be used in \autoref{algorithm:avl:deleteFixNode} and \autoref{algorithm:avl:deleteRotate} where we turned to manual updating of ranks to show the difference.
|
||||||
|
|
||||||
\section{Deletion from the Weak AVL Tree}
|
\section{Deletion from the weak AVL tree}
|
||||||
|
|
||||||
\begin{algorithm}
|
\begin{algorithm}
|
||||||
\Proc{$\texttt{deleteRebalance}(T, y, parent)$}{
|
\Proc{$\texttt{deleteRebalance}(T, y, parent)$}{
|
||||||
|
@ -893,7 +893,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.
|
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:
|
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