\documentclass{scrartcl}
\usepackage{german}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{array}
\usepackage{pgf,tikz}
\usetikzlibrary{positioning,shapes,arrows,decorations.pathreplacing,backgrounds,snakes}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Aufgabe 4a)}

\begin{figure}[h!]

\begin{tikzpicture}[thick]

	%x-Achse
   \draw[thick] (0, -0.2) -- (16, -0.2);
   \draw[snake=ticks,segment length=1cm] (0, -0.2) -- (16, -0.2);
   \foreach \x in {0,...,16} \draw[dotted,gray] (\x, -0.1) -- (\x, -6.25); 
   \foreach \x in {0,...,16} \draw[dotted,gray] (\x, -12.5) -- (\x, -14.5); 
   \foreach \x in {0,...,16} \node[above] at (\x, 0.0) {$\x$};

   \def\y{-1};
   \node[right] at (-0.5, \y) {1.};
   \draw[]                 ( 0, \y+0.25) rectangle (16, \y-0.25);
   
   \def\y{-2};
   \node[right] at (-0.5, \y) {2.};   
   \draw[]                 ( 0, \y+0.25) rectangle (16, \y-0.25);
   
   \def\y{-3};
   \node[right] at (-0.5, \y) {3.};   
   \draw[]                 ( 0, \y+0.25) rectangle (16, \y-0.25);
   
   \def\y{-4};
   \node[right] at (-0.5, \y) {4.};   
   \draw[]                 ( 0, \y+0.25) rectangle (16, \y-0.25);
      
   \def\y{-5};
   \node[right] at (-0.5, \y) {5.};   
   \draw[]                 ( 0, \y+0.25) rectangle (16, \y-0.25);

   \def\y{-6};
   \node[right] at (-0.5, \y) {6.};
   \draw[]                 ( 0, \y+0.25) rectangle ( 4, \y-0.25);   
   \filldraw[fill=gray!20] ( 4, \y+0.25) rectangle ( 8, \y-0.25); \node at (6, \y) {X};      
   \draw[]                 ( 8, \y+0.25) rectangle (12, \y-0.25);
   \draw[]                 ( 12, \y+0.25) rectangle (14, \y-0.25);
   \draw[]                 (14, \y+0.25) rectangle (15, \y-0.25);
   \filldraw[fill=gray!20] (15, \y+0.25) rectangle (16, \y-0.25); \node at (15.5, \y) {Y};   
   
	% Tree structure 
   \draw (14.5, \y-0.25) -- (14.5, \y-0.75);
   \draw (15.5, \y-0.25) -- (15.5, \y-0.75);
   
   \draw (14.5, \y-1.25) -- (15, \y-2.25);
   \draw (15.5, \y-1.25) -- (15, \y-2.25);
   
   \draw (13,   \y-2.25) -- (14, \y-3.25);
   \draw (15,   \y-2.25) -- (14, \y-3.25);   
   
   \draw (14,   \y-3.25) -- (12, \y-4.25);
   \draw (10,   \y-3.25) -- (12, \y-4.25);         
   \draw ( 2,   \y-3.25) -- ( 4, \y-4.25);
   \draw ( 6,   \y-3.25) -- ( 4, \y-4.25);
   
   \draw ( 4,   \y-4.25) -- ( 8, \y-5.25);
   \draw (12,   \y-4.25) -- ( 8, \y-5.25);  

   \draw (13, \y-1.75) -- (13, \y-0.25);       
   \draw (2,  \y-2.75) -- ( 2, \y-0.25);
   \draw (6,  \y-2.75) -- ( 6, \y-0.25);     
   \draw (10, \y-2.75) -- (10, \y-0.25);    
   
   \node[below left ] at ( 8, \y-5.25) {16 MB};
   \node[below left ] at ( 4, \y-4.25) { 8 MB};
   \node[below      ] at (12, \y-4.25) { 8 MB};
   \node[above      ] at ( 2, \y-3.25) { 4 MB};
   \node[above      ] at ( 6, \y-3.25) { 4 MB};   
   \node[above      ] at (10, \y-3.25) { 4 MB};
   \node[below right] at (14, \y-3.25) { 4 MB};
   \node[below right] at (15, \y-2.25) { 2 MB};
   \node[above      ] at (13, \y-2.25) { 2 MB};
   \node[above      ] at (14.5, \y-1.25) { 1 MB};
   \node[above      ] at (15.5, \y-1.25) { 1 MB};

   \def\y{-13};
   \node[right] at (-0.5, \y) {7.};   
   \draw[]                 ( 0, \y+0.25) rectangle (16, \y-0.25);;

   \def\y{-14};
   \node[right] at (-0.5, \y) {8.};   
   \draw[]                 ( 0, \y+0.25) rectangle (16, \y-0.25);
   
\end{tikzpicture}
\caption{Speicherbelegung}
\vspace{1em}
\emph{Bemerkung:} Speicherbelegungen und Baumstruktur sind exemplarisch und müssen entsprechend der Lösung der Aufgabe abgeändert werden.

\end{figure}



\end{document}
