aboutsummaryrefslogtreecommitdiff
path: root/notes/algorithms.tex
diff options
context:
space:
mode:
authorMohit Agarwal <mohit.agarwal@sky.com>2024-01-01 18:55:33 +0000
committerMohit Agarwal <mohit.agarwal@sky.com>2024-01-01 18:55:33 +0000
commiteec6292056e6f6d6aa9f52ed2b71585e60632568 (patch)
tree5f87496cb57f51812871cb53bdbd4199ef0fa24c /notes/algorithms.tex
parent9923e6e6fcc27a1a0f233b13e4c83d5d0c10b4d0 (diff)
RewritingHEADmaster
Diffstat (limited to 'notes/algorithms.tex')
-rw-r--r--notes/algorithms.tex24
1 files changed, 13 insertions, 11 deletions
diff --git a/notes/algorithms.tex b/notes/algorithms.tex
index 4801766..bffe1a9 100644
--- a/notes/algorithms.tex
+++ b/notes/algorithms.tex
@@ -91,11 +91,11 @@ of order so we would swap them. Here are some but not all steps on the
original list $n$
\begin{align*}
- &n = \{2,6,4,7,8,3,9,0\} \mbox{ comparing 2 and 6} \\
- &n = \{2,4,6,7,8,3,9,0\} \mbox{ comparing 6 and 4, \textit{swap}} \\
- &n = \{2,4,6,7,8,3,9,0\} \mbox{ comparing 6 and 7} \\
- &n = \{2,4,6,7,8,3,9,0\} \mbox{ comparing 7 and 8} \\
- &n = \{2,4,6,7,3,8,9,0\} \mbox{ comparing 8 and 3, \textit{swap}} \\
+ &n = \{\color{red}2\color{black},\color{red}6\color{black},4,7,8,3,9,0\} \mbox{ comparing 2 and 6} \\
+ &n = \{2,\color{red}4\color{black},\color{red}6\color{black},7,8,3,9,0\} \mbox{ comparing 6 and 4, \textit{swap}} \\
+ &n = \{2,4,\color{red}6\color{black},\color{red}7\color{black},8,3,9,0\} \mbox{ comparing 6 and 7} \\
+ &n = \{2,4,6,\color{red}7\color{black},\color{red}8\color{black},3,9,0\} \mbox{ comparing 7 and 8} \\
+ &n = \{2,4,6,7,\color{red}3\color{black},\color{red}8\color{black},9,0\} \mbox{ comparing 8 and 3, \textit{swap}} \\
&...
\end{align*}
@@ -111,13 +111,15 @@ sequentially add the smaller value between the lists to the output
\begin{align*}
list\ 1 &&list\ 2 &&output\ list\\
- \{1,3,5\}&&\{2,4,6\}&&\{\} &&\mbox{}\\
- \{3,5\} &&\{2,4,6\}&&\{1\} &&\mbox{Comparing 1 and 2, we start with 1}\\
- \{3,5\} &&\{4,6\} &&\{1,2\} &&\mbox{Comparing 3 and 2, we add 2}\\
- \{5\} &&\{4,6\} &&\{1,2,3\} &&\mbox{Comparing 3 and 4, we add 3}\\
- \{5\} &&\{6\} &&\{1,2,3,4\}&&\mbox{Comparing 5 and 4, we add 4}\\
- \{\} &&\{6\} &&\{1,2,3,4,5\}&&\mbox{Comparing 5 and 6, we add 5}\\
+ \{{\color{red}1},3,5\}&&\{{\color{red}2},4,6\}&&\{\} &&\mbox{}\\
+ \{{\color{red}3},5\} &&\{{\color{red}2},4,6\}&&\{1\} &&\mbox{Comparing 1 and 2, we start with 1}\\
+ \{{\color{red}3},5\} &&\{{\color{red}4},6\} &&\{1,2\} &&\mbox{Comparing 3 and 2, we add 2}\\
+ \{{\color{red}5}\} &&\{{\color{red}4},6\} &&\{1,2,3\} &&\mbox{Comparing 3 and 4, we add 3}\\
+ \{{\color{red}5}\} &&\{{\color{red}6}\} &&\{1,2,3,4\}&&\mbox{Comparing 5 and 4, we add 4}\\
+ \{\} &&\{{\color{red}6}\} &&\{1,2,3,4,5\}&&\mbox{Comparing 5 and 6, we add 5}\\
\{\} &&\{\} &&\{1,2,3,4,5,6\}&&\mbox{Comparing nothing and 6, we add 6}\\
+ \{\} &&\{\} &&\{1,2,3,4,5,6\}&&\mbox{Lists 1 \&
+ 2: we are finished}\\
\end{align*}
\section{Programming languages}