add trees for first part of delete
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
5c11ad4fdc
commit
c9931d0a3d
1 changed files with 111 additions and 0 deletions
111
fi-pdflatex.tex
111
fi-pdflatex.tex
|
@ -759,6 +759,117 @@ In contrast to the \textit{AVL Rule}, WAVL tree allows us to have (2, 2) nodes p
|
|||
\caption{Final phase of the deletion rebalance after deletion from the WAVL tree}\label{algorithm:wavl:fixDelete}
|
||||
\end{algorithm}
|
||||
|
||||
\begin{figure}
|
||||
\centering
|
||||
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.75,]
|
||||
%%
|
||||
\node (Node{1}) at (87.197bp,192.0bp) [draw,ellipse] {1, 2};
|
||||
\node (Node{0}) at (31.197bp,105.0bp) [draw,ellipse] {0, 1};
|
||||
\node (Node{2}) at (106.2bp,105.0bp) [draw,ellipse] {2, 0};
|
||||
\node (Node{-1}) at (31.197bp,18.0bp) [draw,ellipse] {-1, 0};
|
||||
\draw [->] (Node{1}) ..controls (68.373bp,162.43bp) and (56.68bp,144.68bp) .. (Node{0});
|
||||
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
|
||||
\pgfsetstrokecolor{strokecol}
|
||||
\draw (68.197bp,148.5bp) node {1};
|
||||
\draw [->] (Node{1}) ..controls (93.66bp,162.09bp) and (97.18bp,146.34bp) .. (Node{2});
|
||||
\draw (102.2bp,148.5bp) node {2};
|
||||
\draw [->] (Node{0}) ..controls (31.197bp,75.163bp) and (31.197bp,59.548bp) .. (Node{-1});
|
||||
\draw (36.197bp,61.5bp) node {1};
|
||||
%
|
||||
\end{tikzpicture}
|
||||
\caption{WAVL tree with elements inserted in order $(0, 1, 2, -1)$}\label{fig:wavl:deletionA:before}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}
|
||||
\centering
|
||||
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.75,]
|
||||
%%
|
||||
\node (Node{1}) at (31.197bp,192.0bp) [draw,ellipse] {1, 2};
|
||||
\node (Node{0}) at (31.197bp,105.0bp) [draw,ellipse] {0, 1};
|
||||
\node (Node{-1}) at (31.197bp,18.0bp) [draw,ellipse] {-1, 0};
|
||||
\draw [->] (Node{1}) ..controls (31.197bp,162.16bp) and (31.197bp,146.55bp) .. (Node{0});
|
||||
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
|
||||
\pgfsetstrokecolor{strokecol}
|
||||
\draw (36.197bp,148.5bp) node {1};
|
||||
\draw [->] (Node{0}) ..controls (31.197bp,75.163bp) and (31.197bp,59.548bp) .. (Node{-1});
|
||||
\draw (36.197bp,61.5bp) node {1};
|
||||
%
|
||||
\end{tikzpicture}
|
||||
\caption{WAVL tree from \autoref{fig:wavl:deletionA:before} after deletion of 2, value is replaced by one of its children}\label{fig:wavl:deletionA:replacing}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}
|
||||
\centering
|
||||
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.75,]
|
||||
%%
|
||||
\node (Node{0}) at (70.197bp,105.0bp) [draw,ellipse] {0, 1};
|
||||
\node (Node{-1}) at (31.197bp,18.0bp) [draw,ellipse] {-1, 0};
|
||||
\node (Node{1}) at (109.2bp,18.0bp) [draw,ellipse] {1, 2};
|
||||
\draw [->] (Node{0}) ..controls (57.102bp,75.46bp) and (49.394bp,58.66bp) .. (Node{-1});
|
||||
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
|
||||
\pgfsetstrokecolor{strokecol}
|
||||
\draw (58.197bp,61.5bp) node {1};
|
||||
\draw [->] (Node{0}) ..controls (83.292bp,75.46bp) and (91.0bp,58.66bp) .. (Node{1});
|
||||
\draw (98.197bp,61.5bp) node {-1};
|
||||
%
|
||||
\end{tikzpicture}
|
||||
\caption{rotation by parent}\label{fig:my_label}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}
|
||||
\centering
|
||||
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.75,]
|
||||
%%
|
||||
\node (Node{0}) at (70.197bp,105.0bp) [draw=blue,ellipse] {0, 2};
|
||||
\node (Node{-1}) at (31.197bp,18.0bp) [draw,ellipse] {-1, 0};
|
||||
\node (Node{1}) at (109.2bp,18.0bp) [draw,ellipse] {1, 2};
|
||||
\draw [->] (Node{0}) ..controls (57.102bp,75.46bp) and (49.394bp,58.66bp) .. (Node{-1});
|
||||
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
|
||||
\pgfsetstrokecolor{strokecol}
|
||||
\draw (58.197bp,61.5bp) node {2};
|
||||
\draw [->] (Node{0}) ..controls (83.292bp,75.46bp) and (91.0bp,58.66bp) .. (Node{1});
|
||||
\draw (96.197bp,61.5bp) node {0};
|
||||
%
|
||||
\end{tikzpicture}
|
||||
\caption{promotion of y}\label{fig:my_label}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}
|
||||
\centering
|
||||
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.75,]
|
||||
%%
|
||||
\node (Node{0}) at (70.197bp,105.0bp) [draw,ellipse] {0, 2};
|
||||
\node (Node{-1}) at (31.197bp,18.0bp) [draw,ellipse] {-1, 0};
|
||||
\node (Node{1}) at (109.2bp,18.0bp) [draw=blue,ellipse] {1, 1};
|
||||
\draw [->] (Node{0}) ..controls (57.102bp,75.46bp) and (49.394bp,58.66bp) .. (Node{-1});
|
||||
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
|
||||
\pgfsetstrokecolor{strokecol}
|
||||
\draw (58.197bp,61.5bp) node {2};
|
||||
\draw [->] (Node{0}) ..controls (83.292bp,75.46bp) and (91.0bp,58.66bp) .. (Node{1});
|
||||
\draw (96.197bp,61.5bp) node {1};
|
||||
%
|
||||
\end{tikzpicture}
|
||||
\caption{demotion of z}\label{fig:my_label}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}
|
||||
\centering
|
||||
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.75,]
|
||||
%%
|
||||
\node (Node{0}) at (70.197bp,105.0bp) [draw,ellipse] {0, 2};
|
||||
\node (Node{-1}) at (31.197bp,18.0bp) [draw,ellipse] {-1, 0};
|
||||
\node (Node{1}) at (109.2bp,18.0bp) [draw=blue,ellipse] {1, 0};
|
||||
\draw [->] (Node{0}) ..controls (57.102bp,75.46bp) and (49.394bp,58.66bp) .. (Node{-1});
|
||||
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
|
||||
\pgfsetstrokecolor{strokecol}
|
||||
\draw (58.197bp,61.5bp) node {2};
|
||||
\draw [->] (Node{0}) ..controls (83.292bp,75.46bp) and (91.0bp,58.66bp) .. (Node{1});
|
||||
\draw (96.197bp,61.5bp) node {2};
|
||||
%
|
||||
\end{tikzpicture}
|
||||
\caption{second demotion of z}\label{fig:my_label}
|
||||
\end{figure}
|
||||
|
||||
\chapter{Implementation}
|
||||
|
||||
For the implementation of 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 while \texttt{null}-checking is enforced, since, for example, static type control cannot be aware of a node \textbf{not} being a \texttt{null} after checking specific set of conditions that forbid such scenario.
|
||||
|
|
Reference in a new issue