diff options
| author | mithe24 <mithe24@student.sdu.dk> | 2025-10-29 15:25:13 +0100 |
|---|---|---|
| committer | Andreas Kapp Lindquist <andkaplin05@gmail.com> | 2025-10-29 18:33:28 +0100 |
| commit | 48139d1c1d8f4da22a4ea474abe6f1f6aeffcaad (patch) | |
| tree | 88f1bd86f00bb3922c33ec7a7c195aecc7f6bf9e /report/report.tex | |
| parent | 8db3bea514257cf68da8fe4768c5cd84e8f20b78 (diff) | |
| download | sorter-48139d1c1d8f4da22a4ea474abe6f1f6aeffcaad.tar.gz sorter-48139d1c1d8f4da22a4ea474abe6f1f6aeffcaad.zip | |
report(qsort): add part about qsort
Diffstat (limited to 'report/report.tex')
| -rw-r--r-- | report/report.tex | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/report/report.tex b/report/report.tex index 358ac87..7ef00ba 100644 --- a/report/report.tex +++ b/report/report.tex @@ -19,6 +19,8 @@ breaklines]{asm}{#1}} \newcommand{\snippet}[3]{\inputminted[firstline=#1,lastline=#2,linenos, xleftmargin=1.5em, breaklines]{asm}{#3}} +\newcommand{\snippetC}[3]{\inputminted[firstline=#1,lastline=#2,linenos, +xleftmargin=1.5em, breaklines]{c}{#3}} % ---------------------------- \begin{document} @@ -209,6 +211,25 @@ allocate space for the array Go through each element in the array and create a pointer that points to a pair in the pairwise data. +\subsection{quick-sort} +The quick-sort implementation uses \textbf{Hoare partition scheme}, +a \textit{two-way partitioning} approach two pointers scan from opposite ends +of the array toward the middle. The left pointer advances rightward while +pointing at elements smaller than the \textit{pivot}, and the right pointer +advances leftward while pointing at elements larger than the \textit{pivot}. +When both pointers both pointers points at misplaced elements, they swap them. +This continues until the pointers cross, effectively partitioning the array +into two segments. + +\begin{figure}[H] + \snippetC{1}{22}{qsort.c} + \caption{Pseudo code for quick-sort algorithm in c-style}\label{fig:qsort} +\end{figure} + +In order to compare two values in the array. The algorithm \textit{dereferences} +the element, and access the element at the given \textit{index}. +To swap two \textit{sub-arrays}, it simply swap their \textit{pointers} +in the pointer-array. \section{Evaluation} |