Adjusting table rows to a tikz figure
This is more than you asked for, but just to demonstrate a completely different approach to drawing a diagram like that. Like AboAmmar I add the "table" as nodes, using a loop.
\documentclass[10pt]{article}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[
scale=0.75,
yscale=-1
]
% draw horizontal lines with labels
\foreach \nn/\yn [count=\i from 0] in {n/y_n,1/1,2/1,3/2,4/3,5/5,6/8,7/13}
{
\draw [gray] (0, \i+0.5) -- +(15,0);
\node at (14.7,\i) {$\yn$};
\node at (14,\i) {$\nn$};
\ifnum \i=0
\draw [gray] (0, \i-0.5) -- +(15,0);
\fi
}
% draw connections
\draw [ultra thick]
(1,7) |- (3,6) |- (2,7)
(3,6) |- (7,4) |- (5,5) |- (4,7)
(7,5) |- (6,7)
(7,6) -| (8,7)
(7,4) -- (7,1)
(7,3) -| (10,7) -- (9,7)
(10,6) -| (11,7)
(10,5) -| (12,7) -- (13,7);
% draw markers
\draw [draw=none,mark=*,mark size=2mm]
plot coordinates {%
(7,1)
(7,2)
(7,3)(10,3)
(3,4)(7,4)(10,4)
(3,5)(5,5)(7,5)(10,5)(12,5)
(1,6)(3,6)(5,6)(7,6)(8,6)(10,6)(11,6)(12,6)
(1,7)(2,7)(3,7)(4,7)(5,7)(6,7)(7,7)(8,7)(9,7)(10,7)(11,7)(12,7)(13,7)
};
\end{tikzpicture}
\end{document}
Remove the tabular, it won't mix well with the tikz picture. Use instead the following two lines:
\foreach \y[count=\i] in {7,6,...,1} \node at (8,\y){\i};
\foreach \y[count=\i] in {13,8,5,3,2,1,1} \node at (8.9,\i){\y};
to add the numbers to the right of your dots.
\documentclass[10pt]{article}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{booktabs}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
\draw [ultra thick] (-6.,2.)-- (-6.,1.);
\draw [ultra thick] (-6.,2.)-- (-4.,2.);
\draw [ultra thick] (-4.,1.)-- (-4.,4.);
\draw [ultra thick] (0.,7.)-- (0.,1.);
\draw [ultra thick] (-2.,3.)-- (-2.,1.);
\draw [ultra thick] (3.,5.)-- (3.,1.);
\draw [ultra thick] (5.,3.)-- (5.,1.);
\draw [ultra thick] (1.,2.)-- (0.,2.);
\draw [ultra thick] (3.,5.)-- (0.,5.);
\draw [ultra thick] (-4.,4.)-- (0.,4.);
\draw [ultra thick] (-4.,1.)-- (-5.,1.);
\draw [ultra thick] (-2.,1.)-- (-3.,1.);
\draw [ultra thick] (-2.,3.)-- (0.,3.);
\draw [ultra thick] (0.,1.)-- (-1.,1.);
\draw [ultra thick] (1.,2.)-- (1.,1.);
\draw [ultra thick] (3.,1.)-- (2.,1.);
\draw [ultra thick] (3.,2.)-- (4.,2.);
\draw [ultra thick] (4.,2.)-- (4.,1.);
\draw [ultra thick] (5.,1.)-- (6.,1.);
\draw [ultra thick] (5.,3.)-- (3.,3.);
\draw [gray] (-6.5,0.5)-- (9,0.5);
\draw [gray] (-6.5,1.5)-- (9,1.5);
\draw [gray] (-6.5,2.5)-- (9,2.5);
\draw [gray] (-6.5,3.5)-- (9,3.5);
\draw [gray] (-6.5,4.5)-- (9,4.5);
\draw [gray] (-6.5,5.5)-- (9,5.5);
\draw [gray] (-6.5,6.5)-- (9,6.5);
\draw [gray] (-6.5,7.5)-- (9,7.5);
\draw [gray] (-6.5,8.5)-- (9,8.5);
\foreach \y[count=\i] in {7,6,...,1} \node at (8,\y){\i};
\foreach \y[count=\i] in {13,8,5,3,2,1,1} \node at (8.9,\i){\y};
\draw node (-3,-.25) {Symbol \tikz \fill [] circle (0.25cm); denotes one pair of rabbits.};
\fill [] (0.,7.) circle (0.25cm);
\fill [] (0.,6.) circle (0.25cm);
\fill [] (0.,5.) circle (0.25cm);
\fill [] (0.,4.) circle (0.25cm);
\fill [] (0.,3.) circle (0.25cm);
\fill [] (0.,2.) circle (0.25cm);
\fill [] (0.,1.) circle (0.25cm);
\fill [] (-1.,1.) circle (0.25cm);
\fill [] (-2.,1.) circle (0.25cm);
\fill [] (-3.,1.) circle (0.25cm);
\fill [] (-4.,1.) circle (0.25cm);
\fill [] (-5.,1.) circle (0.25cm);
\fill [] (-6.,1.) circle (0.25cm);
\fill [] (-6.,2.) circle (0.25cm);
\fill [] (-4.,2.) circle (0.25cm);
\fill [] (-4.,3.) circle (0.25cm);
\fill [] (-4.,4.) circle (0.25cm);
\fill [] (-2.,3.) circle (0.25cm);
\fill [] (-2.,2.) circle (0.25cm);
\fill [] (1.,2.) circle (0.25cm);
\fill [] (1.,1.) circle (0.25cm);
\fill [] (2.,1.) circle (0.25cm);
\fill [] (3.,1.) circle (0.25cm);
\fill [] (3.,2.) circle (0.25cm);
\fill [] (3.,3.) circle (0.25cm);
\fill [] (3.,4.) circle (0.25cm);
\fill [] (3.,5.) circle (0.25cm);
\fill [] (4.,2.) circle (0.25cm);
\fill [] (4.,1.) circle (0.25cm);
\fill [] (5.,1.) circle (0.25cm);
\fill [] (5.,2.) circle (0.25cm);
\fill [] (5.,3.) circle (0.25cm);
\fill [] (6.,1.) circle (0.25cm);
%\node (tbl) at (9,4.5){
%\begin{tabularx}{.2\textwidth}{cc}
%$n $ & $y_{n}$ \\[20pt]
%1 & 1 \\[20pt]
%2 & 1 \\[20pt]
%3 & 2 \\[20pt]
%4 & 3 \\[20pt]
%5 & 5 \\[20pt]
%6 & 8 \\[20pt]
%7 & 13 \\[20pt]
%\end{tabularx}};
\end{tikzpicture}
\end{document}
If you want to do that with a tabular, here is a solution with a {NiceArray}
of nicematrix
.
\documentclass[10pt]{article}
\usepackage{nicematrix}
\usepackage{tikz}
\pagestyle{empty}
\def \N { \raise-1mm\hbox{\scalebox{2}{$\bullet$}} }
\def \C { \Cdots }
\def \V { \Vdots }
\NiceMatrixOptions
{
rules/width=0.2pt ,
xdots =
{
line-style={solid,thick},
shorten=-0.5mm
}
}
\begin{document}
$\begin{NiceArray}{*{27}{c}}[nullify-dots]
& & & & & & & & & & & & & & & & & & & & & & & & &n&y_n \\ \hline \\
& & & & & & & & & & & &\N& & & & & & & & & & & & &1&1 \\
& & & & & & & & & & & &\V& & & & & & & & & & & & & & \\ \hline \\
& & & & & & & & & & & &\N& & & & & & & & & & & & &2&1 \\
& & & & & & & & & & & &\V& & & & & & & & & & & & & & \\ \hline \\
& & & & & & & & & & & &\N& & &\C& & &\N& & & & & & &3&2 \\
& & & & & & & & & & & &\V& & & & & &\V& & & & & & & & \\ \hline \\
& & & &\N& & & &\C& & & &\N& & & & & &\N& & & & & & &4&3\\
& & & &\V& & & & & & & &\V& & & & & &\V& & & & & & & & \\ \hline \\
& & & &\N& & & &\N& &\C& &\N& & & & & &\N& &\C& &\N& & &5&5\\
& & & &\V& & & &\V& & & &\V& & & & & &\V& & & &\V& & & & \\ \hline \\
\N& &\C& &\N& & & &\N& & & &\N&\C&\N& & & &\N&\C&\N& &\N& & &6&8 \\
\V& & & &\V& & & &\V& & & &\V& &\V& & & &\V& &\V& &\V& & & & \\ \hline \\
\N& &\N&\C&\N& &\N&\C&\N& &\N&\C&\N& &\N& &\N&\C&\N& &\N& &\N&\C&\N&7&13\\
\end{NiceArray}$
\end{document}