aboutsummaryrefslogtreecommitdiff
path: root/report
diff options
context:
space:
mode:
authorNavid Samanghoon <nsama24@student.sdu.dk>2025-10-23 17:41:24 +0200
committermithe24 <mithe24@student.sdu.dk>2025-10-29 13:49:57 +0100
commitf7120b704a721d6bd8158182bf319274a0182544 (patch)
tree614de85ad7660f1f55f380e4b6bdca9bced8f344 /report
parent1a24c65334494372a2985529c54e6f34e2b6a757 (diff)
downloadsorter-f7120b704a721d6bd8158182bf319274a0182544.tar.gz
sorter-f7120b704a721d6bd8158182bf319274a0182544.zip
Wrote about design
Diffstat (limited to 'report')
-rw-r--r--report/report.tex22
1 files changed, 17 insertions, 5 deletions
diff --git a/report/report.tex b/report/report.tex
index 5b0d40e..bcd107a 100644
--- a/report/report.tex
+++ b/report/report.tex
@@ -52,10 +52,11 @@ actual runtime to their theoretical runtimes. These datasets will be ranging fro
cases with duplicates or nearly sorted lists.
\section{Design}
-\begin{itemize}
- \item 3 stage process, read $\rightarrow$ sort $\rightarrow$ print
- \item Array format
-\end{itemize}
+The program is structured into four main phases: reading input, parsing data, sorting, and generating output. Each phase is
+designed to handle a specific task, which creates modulariy and clarity. Whitin each phase a set of functions manage the corresponding
+operations, allowing the programmer to focus on one task at a time. This design also greatly supports debugging
+by simplifying tracking and solving errors. Below is a flowchart visualizing each step, followed by
+a short summary of the program.
\begin{figure}[H]
\centering
@@ -64,7 +65,18 @@ cases with duplicates or nearly sorted lists.
\label{fig:flowchart}
\end{figure}
-\subsection{The Array}
+\textbf{Reading Input:} The input file is given as a command line argument. Each coordinate consists of two values, the first
+coordinate x followed by a tab character, and the second coordinate y followed by a newline character. The first step of the program
+is to find this file, calculate the size of it using a function called \textit{getFileSize}, allocating memory, and saving the
+data.
+
+\textbf{Parsing the data:} Next, the received file is to be parsed, meaning that only useful data will be extracted. This process omits
+the tabs, and newlines, which in turn significantly simplifies iteration through the data, by ensuring that only 8-byte coordinates are left.
+Lastly an important design choice has been creating an array of pointers to each coordinatepair.
+This design is explained in further detail later. All of this logic has been wrapped in a function \textit{make\_array\_from\_file}, which
+utilizes several smaller helper functions to perform this parsing process.
+
+\subsection{Why an array of pointers?}
In order to be a litte more general, and make our program easily expandable to
different types of data, we wanted to create out own array datatype, that
allowes us to sort something more abstract, with respect to a key in that