# why one of the columns is too wide?

why the last column is too wide?

    \begin{table}[!h]
\caption{Total times in second and number of sub-problems of  Algorithm 1,2 and 3}
\label{table2}
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
Name  &  Al & Cycle & TTs &  NSP\\
\hline
P1    &  1  & $(1,2,3,4,5)$ & 3.1 &3\\
\hline
P2 &  2 &  (1,15,7,5,12)  & 17 & 11 \\
\hline
P2 &  3 & $(1,15,7,5,12)$  $(2,9,13,14,8)$ & 97& 36  \\
\hline
P3 &  2 & $(1,7,12,16,19,21,6)$, & 15&14\\
\hline
P4 & 2 &   $(11,28,29,38,44,25,20,37)$ &335& 36\\
\hline
P4 & 3 &   \shortstack{ $(11,28,29,38,44,25,20,37)$,\\   $(18,33,34,24,40,36,41,39)$} &  566 & 91\\
\hline
\multicolumn{5}{@{}l@{}}{ Al: Algorithm; NSP: Number of sub-problems; TTs: Total time in second.}\\
\end{tabular}
\end{table} • Because your table needs to accommodate the text in the last row in five columns. – Masroor Jun 30 at 16:42
• The text in the final \multicolumn is too wide for rest of the table at its natural width; the excess is accumulated in the last column. Use two rows for the description. – egreg Jun 30 at 16:50
• are you sure you want [!h] this usually generates a warning that it's being changed but means not at top or bottom or on a page on its own so gives latex very little option for placing the table other than the end of the document. – David Carlisle Jun 30 at 22:28

\documentclass{article}
\usepackage{makecell}
\begin{document}

\begin{table}[!h]
\caption{Total times in second and number of sub-problems of  Algorithm 1,2 and 3}
\label{table2}
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
Name & Al & Cycle                                                           & TTs & NSP \\ \hline
P1   & 1  & (1,2,3,4,5)                                                     & 3.1 & 3   \\ \hline
P2   & 2  & (1,15,7,5,12)                                                   & 17  & 11  \\ \hline
P2   & 3  & (1,15,7,5,12) (2,9,13,14,8)                                     & 97  & 36  \\ \hline
P3   & 2  & (1,7,12,16,19,21,6),                                            & 15  & 14  \\ \hline
P4   & 2  & (11,28,29,38,44,25,20,37)                                       & 335 & 36  \\ \hline
P4   & 3  & \makecell{(11,28,29,38,44,25,20,37)\\(18,33,34,24,40,36,41,39)} & 566 & 91  \\ \hline
\multicolumn{5}{@{}c@{}}{\makebox[1em]{\parbox{\linewidth}{Al: Algorithm; NSP: Number of sub-problems; TTs: Total time in second.}}} \\
\end{tabular}
\end{table}

\end{document} I suggest you employ a threeparttable environment, with its \tnote directives and tablenotes environment, to force the caption and the footnote material to occupy the same width as the tabular environment does. \documentclass{article}
\usepackage{stackrel,array}
\usepackage[flushleft,para]{threeparttable}
\renewcommand{\TPTtagStyle}{\textit} % optional
\begin{document}
\begin{table}[!h]
\setlength\extrarowheight{2pt} % for a less cramped look
\begin{threeparttable}
\caption{Total times in second and number of sub-problems of algorithm 1, 2 and 3}
\label{table2}
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
Name  &  Al\tnote{a} & Cycle & TTs\tnote{b} &  NSP\tnote{c}\\
\hline
P1 &  1 & $(1,2,3,4,5)$ & 3.1 &3\\
\hline
P2 &  2 &  (1,15,7,5,12)  & 17 & 11 \\
\hline
P2 &  3 & $(1,15,7,5,12)$  $(2,9,13,14,8)$ & 97& 36  \\
\hline
P3 &  2 & $(1,7,12,16,19,21,6)$, & 15&14\\
\hline
P4 & 2 &  $(11,28,29,38,44,25,20,37)$ &335& 36\\
\hline
P4 & 3 &  \shortstack{ $(11,28,29,38,44,25,20,37)^{\mathstrut}$,\\
$(18,33,34,24,40,36,41,39)$} &  566 & 91\\
\hline
\end{tabular}

\smallskip
\footnotesize
\begin{tablenotes}
\item[a] Al: Algorithm
\item[b] TTs: Total time, in seconds
\item[c] NSP: Number of sub-problems.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}