Note 1: ETH::A&D
Note Type: Horvath Cloze
GUID:
M,?u9cw(S%
Before
Front
Back
After
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | {{c1:: \(\sum_{i = 1}^{n} i\log(i)\)}} \(\leq\) {{c2::\(O(n \log(n))\)}} ( |
{{c1:: \(\sum_{i = 1}^{n} i\log(i)\)}} \(\leq\) {{c2::\(O(n \log(n))\)}} (O notation) |
Note 2: ETH::A&D
Note Type: Algorithms
GUID:
nzfDv_KLH2
Before
Front
Back
Worst Case: \(O(n^2)\)
We use \(\Theta(n^2)\) comparisons and \(O(n^2)\) switches.
After
Front
Back
Worst Case: \(O(n^2)\)
We use \(\Theta(n^2)\) comparisons and \(O(n^2)\) switches.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Runtime | Best Case: \(O(n)\)<br>Worst Case: \(O(n^2)\) | Best Case: \(O(n^2)\)<br>Worst Case: \(O(n^2)\) |
Note 3: ETH::A&D
Note Type: Algorithms
GUID:
pOtqbJPwg.
Before
Front
Back
After
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Pseudocode | <img src="paste-e41e8fe78828c54643b03175043cfb7610ff04df.jpg"> | <img src="paste-e41e8fe78828c54643b03175043cfb7610ff04df.jpg"><div>(This has the sorted list at the start thus searches the smallest element)</div> |
Note 4: ETH::A&D
Note Type: Horvath Classic
GUID:
v,>nr{ym:e
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | What is an ADT? | |
| Back | An <b>abstract data type</b> describes a wishlist for operations we want to perform on our data. |
Note 5: ETH::A&D
Note Type: Horvath Cloze
GUID:
xdGDHE`#zR
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | A {{c1:: datastructure}} is the implementation of the wishlist of operations defined in our ADT. |
Note 6: ETH::A&D
Note Type: Horvath Cloze
GUID:
F*Z7jn}vxk
Previous
Note did not exist
New Note
Front
- insert(k, L): insert the key K at the end of the list L
- get(i, L): return the memory address of the i-th key in list L
- delete(k, L): remove the key k from the list L
- insertAfter(k, k', L): inserts the key k' after the key k in the list L
Back
- insert(k, L): insert the key K at the end of the list L
- get(i, L): return the memory address of the i-th key in list L
- delete(k, L): remove the key k from the list L
- insertAfter(k, k', L): inserts the key k' after the key k in the list L
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | The ADT <b>List</b> defines the following operations:<br><ul><li>{{c1:: <b>insert(k, L)</b>}}: {{c2:: insert the key <b>K</b> at the end of the list <b>L</b>}}</li><li>{{c3:: <b>get(i, L)</b>}}: {{c4:: return the memory address of the i-th key in list <b>L</b> }}</li><li>{{c4:: <b>delete(k, L)</b>}}: {{c5:: remove the key <b>k</b> from the list <b>L</b>}}</li><li>{{c6::<b>insertAfter(k, k', L)</b>}}: {{c7:: inserts the key <b>k'</b> after the key <b>k</b> in the list <b>L</b>}}</li></ul> |
Note 7: ETH::A&D
Note Type: Horvath Classic
GUID:
ruU|XgSe,e
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | What extra pointer does the ADT List store? | |
| Back | It stores an extra pointer to the end of the list (in a LinkedList to the last node, in an array to delimit the last element). |
Note 8: ETH::A&D
Note Type: Horvath Cloze
GUID:
s6a5!K0P)L
Previous
Note did not exist
New Note
Front
| Operation | Array | Singly Linked List | Doubly Linked List |
|---|---|---|---|
insert(k,L) |
\(O(1)\) | \(O(1)\) | \(O(1)\) |
get(i,L) |
\(O(1)\) | \(O(l)\) | \(O(j)\) |
insertAfter(k,k',L) |
\(O(l)\) | \(O(1)\) | \(O(1)\) |
delete(k,L) |
\(O(l)\) | \(O(l)\) | \(O(1)\) |
We assume to have a pointer to the end of the list here. |
Back
| Operation | Array | Singly Linked List | Doubly Linked List |
|---|---|---|---|
insert(k,L) |
\(O(1)\) | \(O(1)\) | \(O(1)\) |
get(i,L) |
\(O(1)\) | \(O(l)\) | \(O(j)\) |
insertAfter(k,k',L) |
\(O(l)\) | \(O(1)\) | \(O(1)\) |
delete(k,L) |
\(O(l)\) | \(O(l)\) | \(O(1)\) |
We assume to have a pointer to the end of the list here. |
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | <table> <tbody><tr> <th>Operation</th> <th>Array</th> <th>Singly Linked List</th> <th>Doubly Linked List</th> </tr> <tr> <td><code>insert(k,L)</code></td> <td>{{c1:: \(O(1)\)}}</td> <td>{{c2:: \(O(1)\)}}</td> <td>{{c3:: \(O(1)\)}}</td> </tr> <tr> <td><code>get(i,L)</code></td> <td>{{c4:: \(O(1)\)}}</td> <td>{{c5:: \(O(l)\)}}</td> <td>{{c6:: \(O(j)\)}}</td> </tr> <tr> <td><code>insertAfter(k,k',L)</code></td> <td>{{c7:: \(O(l)\)}}</td> <td>{{c8:: \(O(1)\)}}</td> <td>{{c9:: \(O(1)\)}}</td> </tr> <tr> <td><code>delete(k,L)</code></td> <td>{{c10:: \(O(l)\)}}</td> <td>{{c11:: \(O(l)\)}}</td> <td>{{c12:: \(O(1)\)}}</td> </tr> <tr> <td><em><br>We assume to have a pointer to the end of the list here.</em></td> <td></td> <td></td> <td></td> </tr></tbody></table> |
Note 9: ETH::A&D
Note Type: Horvath Classic
GUID:
qBT+Ifr6uX
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | In what situation is the array the correct datastructure? | |
| Back | When we have a fixed upper bound for the size of the list. |
Note 10: ETH::A&D
Note Type: Horvath Cloze
GUID:
HNA(>OC%7u
Previous
Note did not exist
New Note
Front
- Insert in \(O(1)\) as we know the first empty cell in the array and can just write the key there
- Get in \(O(1)\) as we know the offset for each key
- InsertAfter in \(\Theta(l)\), since we have to shift the entire contents of the array behind the newly inserted element by 1.
- Delete in \(\Theta(l)\) as in the worst case (Delete first element) we need to shift all to the left by 1.
Back
- Insert in \(O(1)\) as we know the first empty cell in the array and can just write the key there
- Get in \(O(1)\) as we know the offset for each key
- InsertAfter in \(\Theta(l)\), since we have to shift the entire contents of the array behind the newly inserted element by 1.
- Delete in \(\Theta(l)\) as in the worst case (Delete first element) we need to shift all to the left by 1.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | In an array we can:<br><ul><li><b>Insert</b> in {{c1:: \(O(1)\) as we know the first empty cell in the array and can just write the key there}}</li><li><b>Get</b> in {{c2::\(O(1)\) as we know the offset for each key}}</li><li><b>InsertAfter</b> in {{c3::\(\Theta(l)\), since we have to shift the entire contents of the array behind the newly inserted element by 1.}}<br></li><li><b>Delete</b> in {{c4::\(\Theta(l)\) as in the worst case (Delete first element) we need to shift all to the left by 1.}}<br></li></ul> |
Note 11: ETH::A&D
Note Type: Horvath Cloze
GUID:
rp1#iPsvnq
Previous
Note did not exist
New Note
Front
We also have an extra pointer to the end in practice.
Back
We also have an extra pointer to the end in practice.
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}}. | |
| Extra | The last pointer of the list is a null pointer to indicate the end. |
Note 12: ETH::A&D
Note Type: Horvath Cloze
GUID:
D!4=n6GM2_
Previous
Note did not exist
New Note
Front
This increases memory usage as a trade-off for speed.
Back
This increases memory usage as a trade-off for speed.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | In a <b>doubly linked list</b>, we store a pointer to the {{c1:: previous and next element}} for each key.<br><br>This increases {{c2::memory usage}} as a trade-off for {{c2:: speed}}. |
Note 13: ETH::A&D
Note Type: Horvath Cloze
GUID:
Pf|C9|^n[w
Previous
Note did not exist
New Note
Front
- Insert is \(\Theta(1)\) as we know the memory address of the final element in the list and just have to set the null pointer to the new keys address. Without this pointer it's \(\Theta(l)\).
- Get is \(\Theta(i)\) very slow as we need to traverse the entire list up to i
- insertAfter is \(O(1)\) if we get the memory address of the element to insert after.
- delete is:
SLL: {{c4::\(\Theta(l)\) as we need to find the previous element and change it's pointer.}
DLL: \(O(1)\) we know the address of the previous element and then just edit it's pointer.
Back
- Insert is \(\Theta(1)\) as we know the memory address of the final element in the list and just have to set the null pointer to the new keys address. Without this pointer it's \(\Theta(l)\).
- Get is \(\Theta(i)\) very slow as we need to traverse the entire list up to i
- insertAfter is \(O(1)\) if we get the memory address of the element to insert after.
- delete is:
SLL: {{c4::\(\Theta(l)\) as we need to find the previous element and change it's pointer.}
DLL: \(O(1)\) we know the address of the previous element and then just edit it's pointer.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | In a <b>singly</b> and <b>doubly linked list</b>, the operation:<br><ul><li><b>Insert</b> is {{c1::\(\Theta(1)\) as we know the memory address of the final element in the list and just have to set the null pointer to the new keys address. Without this pointer it's \(\Theta(l)\). }}<br></li><li><b>Get</b> is {{c2::\(\Theta(i)\) very slow as we need to traverse the entire list up to <b>i</b>}}<br></li><li><b>insertAfter</b> is {{c3:: \(O(1)\) if we get the memory address of the element to insert after.}}<br></li><li><b>delete</b> is:<br> SLL: {{c4::\(\Theta(l)\) as we need to find the previous element and change it's pointer.}<br> DLL: {{c5:: \(O(1)\) we know the address of the previous element and then just edit it's pointer.}}</li></ul> |
Note 14: ETH::A&D
Note Type: Horvath Cloze
GUID:
OGBoPi1aY*
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | The ADTs {{c2::<b>stack</b> and <b>queue</b>}} behave similarly to a {{c1:: list}}, but with {{c3:: more constrained operations that allow more efficient computation}}. |
Note 15: ETH::A&D
Note Type: Horvath Cloze
GUID:
Ah6X9iAj
Previous
Note did not exist
New Note
Front
- push(k, S): push a new object k to the top of the stack S
- pop(S): remove and return the top element of the stack S
- top(S): get the top element of the stack S without deleting it
Back
- push(k, S): push a new object k to the top of the stack S
- pop(S): remove and return the top element of the stack S
- top(S): get the top element of the stack S without deleting it
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | The ADT <b>stack</b> has the following operations:<br><ul><li>{{c1:: <b>push(k, S)</b>}}: {{c2:: push a new object <b>k</b> to the top of the stack <b>S</b>}}</li><li>{{c3:: <b>pop(S)</b>}}: {{c4:: remove and return the top element of the stack <b>S</b>}}</li><li>{{c5:: <b>top(S)</b>}}: {{c6:: get the top element of the stack <b>S</b> without deleting it}}</li></ul> | |
| Extra | Other operations might be <b>isEmpty</b> or <b>emptystack</b> which produces and emtpy stack. |
Note 16: ETH::A&D
Note Type: Horvath Cloze
GUID:
nK{)v6I%zc
Previous
Note did not exist
New Note
Front
- 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.
Back
- 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> |
Note 17: ETH::A&D
Note Type: Horvath Cloze
GUID:
u)lmsqp*H!
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | A stack is also called a {{c1:: LIFO}} queue. |
Note 18: ETH::A&D
Note Type: Horvath Cloze
GUID:
yy3TxuBe~r
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | A queue is also called {{c1:: FIFO}}. |
Note 19: ETH::A&D
Note Type: Horvath Cloze
GUID:
D2>~h
Previous
Note did not exist
New Note
Front
- enqueue(k, S): append at the end of the queue
- dequeue(S): remove and return the first element of the queue
Back
- enqueue(k, S): append at the end of the queue
- dequeue(S): remove and return the first element of the queue
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | The ADT <b>quue</b> has the following operations:<br><ul><li>{{c1:: <b>enqueue(k, S)</b>}}: {{c2:: append at the end of the queue}}</li><li>{{c3:: <b>dequeue(S)</b>}}: {{c4:: remove and return the first element of the queue}}</li></ul> |
Note 20: ETH::A&D
Note Type: Horvath Cloze
GUID:
F^&OZQURkx
Previous
Note did not exist
New Note
Front
- push: \(O(1)\) insert at the end, with pointer to the end
- pop: \(O(1)\) remove the first element like in a stack
Back
- 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> |
Note 21: ETH::A&D
Note Type: Horvath Cloze
GUID:
s++QypVica
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | A <b>PriorityQueue</b> is like a queue, with the difference that {{c1:: every key is associated with a natural number which indicates the importance}}. | |
| Extra | The elements are then returned in the order of this importance. |
Note 22: ETH::A&D
Note Type: Horvath Cloze
GUID:
Ld,vXkta~C
Previous
Note did not exist
New Note
Front
- insert: insert with priority p
- extractMax: removes and returns element with highest priority.
Back
- insert: insert with priority p
- extractMax: removes and returns element with highest priority.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | The ADT <b>priorityQueue</b> has the following operations:<br><ul><li><b>{{c1:: insert}}</b>: {{c2::insert with priority <b>p}}</b><br></li><li><b>{{c3:: extractMax}}</b>: {{c4::removes and returns element with highest priority.}}<br></li></ul> |
Note 23: ETH::A&D
Note Type: Horvath Cloze
GUID:
t/(N7FzdP}
Previous
Note did not exist
New Note
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | <div>The ADT <b>priorityQueue</b> can be efficiently implemented using a {{c1:: <b>MaxHeap</b>}}. This guarantees {{c2:: \(O(\log n)\)}} for both operations.</div> |
Note 24: ETH::DiskMat
Note Type: Horvath Cloze
GUID:
Mqpm#lUsGl
Before
Front
A function \(f: A \rightarrow A\) has a right inverse if and only if \(f\) is surjective.
Back
A function \(f: A \rightarrow A\) has a right inverse if and only if \(f\) is surjective.
After
Front
A function \(f: A \rightarrow B\) has a right inverse if and only if \(f\) is surjective.
Back
A function \(f: A \rightarrow B\) has a right inverse if and only if \(f\) is surjective.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | <p>A function \(f: A \rightarrow |
<p>A function \(f: A \rightarrow B\) has a {{c1::right inverse}} if and only if \(f\) is {{c2::surjective}}.</p> |
Note 25: ETH::DiskMat
Note Type: Horvath Cloze
GUID:
HM@g5s7n?R
Before
Front
A function \(f: A \rightarrow A\) has an inverse \(f^{-1}\) if and only if \(f\) is bijective.
Back
A function \(f: A \rightarrow A\) has an inverse \(f^{-1}\) if and only if \(f\) is bijective.
After
Front
A function \(f: A \rightarrow B\) has an inverse \(f^{-1}\) if and only if \(f\) is bijective.
Back
A function \(f: A \rightarrow B\) has an inverse \(f^{-1}\) if and only if \(f\) is bijective.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | <p>A function \(f: A \rightarrow |
<p>A function \(f: A \rightarrow B\) has an {{c1::inverse}} \(f^{-1}\) if and only if \(f\) is {{c2::bijective}}.</p> |
Note 26: ETH::DiskMat
Note Type: Horvath Classic
GUID:
vx[#sC8q?V
Before
Front
What property does every finite field \(\text{GF}(q)\) have (and what does \(q\) satisfy)?
Back
What property does every finite field \(\text{GF}(q)\) have (and what does \(q\) satisfy)?
Theorem 5.40: The multiplicative group of every finite field \(\text{GF}(q)\) is cyclic (as \(q\) is a power of a prime, if \(\text{GF}(q)\) is cyclic).
This group has order \(q - 1\) and \(\varphi(q-1)\) generators.
After
Front
What property does every finite field \(\text{GF}(q)\) have (and what does \(q\) satisfy)?
Back
What property does every finite field \(\text{GF}(q)\) have (and what does \(q\) satisfy)?
Theorem 5.40: The multiplicative group of every finite field \(\text{GF}(q)\) is cyclic (as \(q\) is a power of a prime, if \(\text{GF}(q)\) is cyclic).
This group has order \(q - 1\) and \(\varphi(q-1)\) generators.
Note that even though q is not prime thus not every integer is comprime, GF(q) is not Z_q.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Back | <p><strong>Theorem 5.40</strong>: The multiplicative group of every finite field \(\text{GF}(q)\) is cyclic (as \(q\) is a power of a prime, if \(\text{GF}(q)\) is cyclic).</p> <p>This group has order \(q - 1\) and \(\varphi(q-1)\) generators.</p> | <p><strong>Theorem 5.40</strong>: The multiplicative group of every finite field \(\text{GF}(q)\) is cyclic (as \(q\) is a power of a prime, if \(\text{GF}(q)\) is cyclic).</p> <p>This group has order \(q - 1\) and \(\varphi(q-1)\) generators.</p><p><i>Note that even though q is not prime thus not every integer is comprime, GF(q) is <b>not</b> Z_q.</i></p> |