From 2090f033fac0ef8d69a3ae67289296065ea6cd99 Mon Sep 17 00:00:00 2001 From: Andreas Kapp Lindquist Date: Wed, 29 Oct 2025 17:31:53 +0100 Subject: report(array maker): Finish --- report/report.tex | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'report/report.tex') diff --git a/report/report.tex b/report/report.tex index ea688ac..7456acb 100644 --- a/report/report.tex +++ b/report/report.tex @@ -198,12 +198,17 @@ in memory. It then passes this address, and the length of the file onto the function \texttt{make\_pairwise\_data}. This function removes \texttt{\textbackslash t} and \texttt{\textbackslash n}, and puts the integers side-by-side, with space for 64-bit integers. This format is nice, because it -allows us to iterate over the number of coordinates, and select every $2n$ pair -as the place in memory where the $n^\text{th}$ pair in the array points to. - - +allows us to iterate over the number of coordinates, and select every pair $i$ +by going to position $2i$, and using that as the place in memory where the +$i^\text{th}$ pair in the array points to. The psudocode for this can be seen on +\autoref{fig:arraymaker}.\footnote{The assembly code is quite easy to interpret +from this psudocode, hence the psudocode instead of assembly. This also makes it +easier to understand.} + +\vspace{10pt} \begin{algorithm}[H] \DontPrintSemicolon % optional: removes ; + \SetAlgoNoLine \SetKwInOut{Input}{Input} \SetKwInOut{Output}{Output} @@ -217,24 +222,14 @@ as the place in memory where the $n^\text{th}$ pair in the array points to. $p,n\leftarrow$ make\_pairwise\_data($p,n$)\\ \texttt{// Allocate space for final array, and save pointer in $A$}\\ $A\leftarrow$ allocate($8n$)\\ - \Return $p$ and $n$ - - \caption{Quicksort} + \texttt{// Put memmory address of pair $i$ at index $i$ in $A$}\\ + \For{$i\leftarrow 0$ \KwTo $n-1$}{ + $A[i]\leftarrow$ mem\_addr($p[2i]$) + } + \Return $A$ and $n$ + \caption{Pseudocode for \texttt{array\_maker}}\label{fig:arraymaker} \end{algorithm} -\begin{figure}[H] - \caption{Psudocode of \texttt{array\_maker.s}}\label{fig:arraysnippet} -\end{figure} - -Load file in memory - -create pairwise data - -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 -- cgit v1.2.3-70-g09d2