The ADT queue can be efficiently implemented using a singly linked list with a pointer to the end:
push: \(O(1)\) insert at the end, with pointer to the end
pop: \(O(1)\) remove the first element like in a stack
Field-by-field Comparison
Field
Before
After
Text
The ADT <b>queue</b> can be efficiently implemented using a {{c1:: <b>singly linked list with a pointer to the end</b>}}:<br><ul><li><b>push</b>: {{c2:: \(O(1)\) insert at the end, with pointer to the end}}<br></li><li><b>pop</b>: {{c3:: \(O(1)\) remove the first element like in a stack}}</li></ul>
The ADT <b>queue</b> can be efficiently implemented using a {{c1::<b>singly linked list with a pointer to the end</b>}}:<br><ul><li><b>push</b>: {{c2:: \(O(1)\) insert at the end, with pointer to the end}}<br></li><li><b>pop</b>: {{c3:: \(O(1)\) remove the first element like in a stack}}</li></ul>
Search for the correct node under which the key is inserted: \(O(\log_2 n)\)
Insert the new key value as a separator
Rebalance (if necessary, i.e. more than 3 keys)
split node into two nodes (each gets 2 children and 1 seps)
the middle sep is pushed to the parent level (and propagate)
The rebalancing being recursively pushed to the parent limits the operations at the height \(h\) thus we get \(O(\log n)\).
Field-by-field Comparison
Field
Before
After
Text
<b>2-3 Tree</b>: Inserting Steps:<br><ol><li>{{c1::Search for the correct node under which the key is inserted: \(O(\log_2 n)\)}}</li><li>{{c2::Insert the new key value as a <b>separator</b>}}</li><li>{{c3::<b>Rebalance</b> (if necessary, i.e. more than 3 keys)<br></li></ol><ul><li>split node into two nodes (each gets 2 children and 1 seps)</li><li>the middle sep is pushed to the parent level (and propagate)}}</li></ul>
<b>2-3 Tree</b>: Insertion steps:<br><ol><li>{{c1::Search for the correct node under which the key is inserted: \(O(\log_2 n)\)}}</li><li>{{c2::Insert the new key value as a <b>separator</b>}}</li><li>{{c3::<b>Rebalance</b> (if necessary, i.e. more than 3 keys)<br></li></ol><ul><li>split node into two nodes (each gets 2 children and 1 seps)</li><li>the middle sep is pushed to the parent level (and propagate)}}</li></ul>
Base Case: Let \(n = 5\) .... So the property holds for \(n = 5\). Induction Hypothesis: We assume the property is true for some \(k \geq 5\) Induction Step: We must show that the property holds for \(k + 1\).
By the principle of mathematical induction ... is true for all \(n \geq 5\).
Base Case: Let \(n = 5\) .... So the property holds for \(n = 5\). Induction Hypothesis: We assume the property is true for some \(k \geq 5\) Induction Step: We must show that the property holds for \(k + 1\).
By the principle of mathematical induction ... is true for all \(n \geq 5\).
Search for the correct node under which the key is inserted: \(O(\log_2 n)\)
Remove the leaf with the value and one separator
Rebalance (if necessary, i.e. now 1 key)
Field-by-field Comparison
Field
Before
After
Text
<b>2-3 Tree</b>: Deleting Steps:<br><ol><li>{{c1::Search for the correct node under which the key is inserted: \(O(\log_2 n)\)}}</li><li>{{c2::Remove the leaf with the value and one separator}}</li><li>{{c3::<b>Rebalance</b> (if necessary, i.e. now 1 key)}}</li></ol>
<b>2-3 Tree</b>: Deletion steps:<br><ol><li>{{c1::Search for the correct node under which the key is inserted: \(O(\log_2 n)\)}}</li><li>{{c2::Remove the leaf with the value and one separator}}</li><li>{{c3::<b>Rebalance</b> (if necessary, i.e. now 1 key)}}</li></ol>
2-3 Tree: We deleted a node and now it's sibling is an only child. What happens if it's neighbor has 2 keys?
The nodes \(u\) and \(v\) are merged to form one new node with 3 children.
The separator from the parent node is pulled down to be the new \(s_2\).
Parent may lose child -> rebalance there (can go up to the root). If root has 1 child -> root replaced by child.
Field-by-field Comparison
Field
Before
After
Front
2-3 Tree: Deleting Steps if neighbour has 2 keys:
2-3 Tree: We deleted a node and now it's sibling is an only child. What happens if it's neighbor has 2 keys?
Back
<ol><li>the nodes \(u\) and \(v\) are <b>merged</b> to form one new node with <b>3 children</b>.</li><li>The separator from the parent node is pulled down to be the new \(s_2\).</li></ol>Parent may lose child -> rebalance there (can go up to the root).<br>If root has 1 child -> root replaced by child.<br><img src="paste-fcffee6f619138677fc86eb74beebfaa266c8cfe.jpg">
<ol><li>The nodes \(u\) and \(v\) are <b>merged</b> to form one new node with <b>3 children</b>.</li><li>The separator from the parent node is pulled down to be the new \(s_2\).</li></ol>Parent may lose child -> rebalance there (can go up to the root).<br>If root has 1 child -> root replaced by child.<br><img src="paste-fcffee6f619138677fc86eb74beebfaa266c8cfe.jpg">
Our current node adopts one of the children. The separators have to be updated by “rotating them”. The parent sep moves with the adopted and the left sep becomes the new parent).
2-3 Tree: We deleted a node and now it's sibling is an only child. What happens if it's neighbor has 3 keys?
Our current node adopts one of the children. The separators have to be updated by “rotating them”. The parent sep moves with the adopted and the left sep becomes the new parent).
Field-by-field Comparison
Field
Before
After
Front
<b>2-3 Tree</b>: Deleting Steps if neighbour has 3 keys:
<b>2-3 Tree</b>: We deleted a node and now it's sibling is an only child. What happens if it's neighbor has 3 keys?
The ADT stack can be efficiently implemented using a singly linked list:
push: \(\Theta(1)\)
pop: \(\Theta(1)\) as this removes the first element. This means we just copy the pointer next from the first element to be the first pointer of the list.
The ADT stack can be efficiently implemented using a singly linked list:
push: \(\Theta(1)\)
pop: \(\Theta(1)\) as this removes the first element. This means we just copy the pointer next from the first element to be the first pointer of the list.
The ADT stack can be efficiently implemented using a singly linked list:
push: \(\Theta(1)\)
pop: \(\Theta(1)\) as this removes the first element. This means we just copy the pointer next from the first element to be the first pointer of the list.
The ADT stack can be efficiently implemented using a singly linked list:
push: \(\Theta(1)\)
pop: \(\Theta(1)\) as this removes the first element. This means we just copy the pointer next from the first element to be the first pointer of the list.
Field-by-field Comparison
Field
Before
After
Text
The ADT <b>stack</b> can be efficiently implemented using a {{c1:: <b>singly linked list</b>}}:<br><ul><li><b>push</b>: {{c2:: \(\Theta(1)\)}}<br></li><li><b>pop</b>: {{c3:: \(\Theta(1)\) as this removes the first element. This means we just copy the pointer next from the first element to be the first pointer of the list.}}<br></li></ul>
The ADT <b>stack</b> can be efficiently implemented using a {{c1::<b>singly linked list</b>}}:<br><ul><li><b>push</b>: {{c2:: \(\Theta(1)\)}}<br></li><li><b>pop</b>: {{c3:: \(\Theta(1)\) as this removes the first element. This means we just copy the pointer next from the first element to be the first pointer of the list.}}<br></li></ul>
In a linked list, the keys don't appear in order in memory. They each contain a pointer to the next element in the list instead.
We also have an extra pointer to the end.
The last pointer of the list is a null pointer to indicate the end.
Field-by-field Comparison
Field
Before
After
Text
In a <b>linked list</b>, the keys {{c1::don't appear in order in memory}}. They each contain {{c2::a pointer to the start of the next element in the list instead}}.<br><br>We also have {{c3::an extra pointer to the end in practice}}.
In a <b>linked list</b>, the keys {{c1::don't appear in order in memory}}. They each contain {{c2::a pointer to the next element in the list instead}}.<br><br>We also have {{c3::an extra pointer to the end}}.
If \(F \vdash_K G\) in a calculus \(K\), one could extend the calculus by the new derivation \(F \rightarrow G\).
Field-by-field Comparison
Field
Before
After
Text
If \(F \vdash_K G\) in a calculus \(K\), one could {{c1::<i>extend the calculus</i> by the new derivation \(\emptyset \vdash F \rightarrow G\)}}.
If \(F \vdash_K G\) in a calculus \(K\), one could {{c1::<i>extend the calculus</i> by the new derivation \(F \rightarrow G\)}}.
The Diffie-Hellman Key-Agreement selects two public values:
a large prime \(p\)
basis \(g\) which is then exponentiated
Field-by-field Comparison
Field
Before
After
Text
DHKE selects two public values:<br><ol><li>{{c1:: a large prime \(p\)}}</li><li>{{c2:: basis \(g\) which is then exponentiated}}</li></ol>
The Diffie-Hellman Key-Agreement selects two public values:<br><ol><li>{{c1:: a large prime \(p\)}}</li><li>{{c2:: basis \(g\) which is then exponentiated}}</li></ol>
Does every homomorphism have to be injective? (Example)
No, homomorphisms do not need to be injective.
Example: We could map all elements of \(G\) to the neutral element \(e'\) in \(H\). This satisfies the homomorphism property: \[\psi(a * b) = e' = e' \star e' = \psi(a) \star \psi(b)\] but it clearly is not injective.
Example: We could map all elements of \(G\) to the neutral element \(e'\) in \(H\). This satisfies the homomorphism property: \[\psi(a * b) = e' = e' \star e' = \psi(a) \star \psi(b)\] but it clearly is not injective.
Field-by-field Comparison
Field
Before
After
Front
<p>Does every homomorphism have to be injective? (Example)</p>
<p>Does every homomorphism have to be injective?</p>
Give an example of an element with infinite order.
In the group \(\langle \mathbb{Z}; + \rangle\), any integer \(a \neq 0\) has infinite order.
Explanation: The carrier \(\mathbb{Z}\) is infinite, and we never "loop around" to reach \(0\) by repeatedly adding a non-zero integer. For any \(n \geq 1\), we have \(na \neq 0\) if \(a \neq 0\).
Provide an example of an element with infinite order.
In the group \(\langle \mathbb{Z}; + \rangle\), any integer \(a \neq 0\) has infinite order.
Explanation: The carrier \(\mathbb{Z}\) is infinite, and we never "loop around" to reach \(0\) by repeatedly adding a non-zero integer. For any \(n \geq 1\), we have \(na \neq 0\) if \(a \neq 0\).
Field-by-field Comparison
Field
Before
After
Front
<p>Give an example of an element with infinite order.</p>
<p>Provide an example of an element with infinite order.</p>
A cyclic group of order \(n\) {{c1::is isomorphic to \(\langle \mathbb{Z}_n,\oplus)\), and hence commutative.::has which useful property?}}
Field-by-field Comparison
Field
Before
After
Text
A cyclic group of order \(n\) {{c1::is isomorphic to \(\langle \mathbb{Z}_n,\oplus)\), and hence commutative::has which useful property?}}.
A cyclic group of order \(n\) {{c1::is isomorphic to \(\langle \mathbb{Z}_n,\oplus)\), and hence commutative.::has which useful property?}}
3. Assume that \( S \) is false and prove that \( T \) is true (-> contradiction).
Field-by-field Comparison
Field
Before
After
Text
Proof method: Proof by Contradiction<br><br>1. {{c1:: Find a suitable statement \( T\)}}<div>2. {{c2:: Prove that \( T \) is false}}</div><div>3. {{c3:: Assume that \( S \) is false and prove that \( T \) is true (-> contradiction)}}</div>
Proof method: Proof by Contradiction<br><br>1. {{c1:: Find a suitable statement \( T\).}}<div>2. {{c2:: Prove that \( T \) is false.}}</div><div>3. {{c3:: Assume that \( S \) is false and prove that \( T \) is true (-> contradiction).}}</div>
The triangle inequality \(||v|| + ||w|| \geq ||v+w||\) holds exactly if \(w = \lambda v\) for some \(\lambda\geq0\) (i.e., they point in the same direction).
The triangle inequality \(||v|| + ||w|| \geq ||v+w||\) holds exactly if \(w = \lambda v\) for some \(\lambda\geq0\) (i.e., they point in the same direction).
Field-by-field Comparison
Field
Before
After
Text
The triangle inequality \(||v|| + ||w|| \geq ||v+w||\) holds exactly if {{c1::\(\exists \lambda \) s.t. \(w = \lambda v\) (i.e. they are scalar multiples)}}
The triangle inequality \(||v|| + ||w|| \geq ||v+w||\) holds exactly if {{c1::\(w = \lambda v\) for some \(\lambda\geq0\) (i.e., they point in the same direction)}}.