diff options
| author | Andreas Kapp Lindquist <andkaplin05@gmail.com> | 2025-10-29 17:31:53 +0100 |
|---|---|---|
| committer | Andreas Kapp Lindquist <andkaplin05@gmail.com> | 2025-10-29 18:33:28 +0100 |
| commit | 2090f033fac0ef8d69a3ae67289296065ea6cd99 (patch) | |
| tree | 2de453f8abdc6c8e0502669c4a9c6fabb137c4e0 /report/report.tex | |
| parent | 6ee05e0790fe0f830ca5b065ab190d8c39e70482 (diff) | |
| download | sorter-2090f033fac0ef8d69a3ae67289296065ea6cd99.tar.gz sorter-2090f033fac0ef8d69a3ae67289296065ea6cd99.zip | |
report(array maker): Finish
Diffstat (limited to 'report/report.tex')
| -rw-r--r-- | report/report.tex | 33 |
1 files changed, 14 insertions, 19 deletions
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 |