Kruskal's Algorithm can be executed in \(O(|E| + |V|\log|V|)\) time?
Note 1: ETH::1. Semester::A&D
Deck: ETH::1. Semester::A&D
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
CJsa&>C5sO
Before
Front
Back
Kruskal's Algorithm can be executed in \(O(|E| + |V|\log|V|)\) time?
No, we need to sort the edges which takes at least \(|E| \log |E|\) time.
After
Front
Can Kruskal's Algorithm be executed in \(O(|E| + |V|\log|V|)\) time?
Back
Can Kruskal's Algorithm be executed in \(O(|E| + |V|\log|V|)\) time?
No, we need to sort the edges which takes at least \(|E| \log |E|\) time.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | Kruskal's Algorithm |
Can Kruskal's Algorithm be executed in \(O(|E| + |V|\log|V|)\) time? |
Note 2: ETH::1. Semester::A&D
Deck: ETH::1. Semester::A&D
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
c1d=kD*#nb
Before
Front
How do we prove/disprove such as statement "There exists at least one undirected graph with 7 vertices in which all vertices have degree 3."
Back
How do we prove/disprove such as statement "There exists at least one undirected graph with 7 vertices in which all vertices have degree 3."
We use the handshake Lemma: \(\sum \deg(v) = 7 \cdot 3 = 2 |E|\) but 21 is not even. Thus this cannot be true.
After
Front
How do we prove/disprove such a statement?
"There exists at least one undirected graph with 7 vertices in which all vertices have degree 3."
"There exists at least one undirected graph with 7 vertices in which all vertices have degree 3."
Back
How do we prove/disprove such a statement?
"There exists at least one undirected graph with 7 vertices in which all vertices have degree 3."
"There exists at least one undirected graph with 7 vertices in which all vertices have degree 3."
We use the handshake Lemma: \(\sum \deg(v) = 7 \cdot 3 = 2 |E|\) but 21 is not even. Thus this cannot be true.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | How do we prove/disprove such a |
How do we prove/disprove such a statement?<br><br>"There exists at least one undirected graph with 7 vertices in which all vertices have degree 3." |
Note 3: ETH::1. Semester::A&D
Deck: ETH::1. Semester::A&D
Note Type: Horvath Cloze
GUID:
modified
Note Type: Horvath Cloze
GUID:
kCvO2]PU.a
Before
Front
\(\ln(1)= 0\).
Back
\(\ln(1)= 0\).
After
Front
\(\ln(1)= {{c1:: 0::\text{Number} }}\)
Back
\(\ln(1)= {{c1:: 0::\text{Number} }}\)
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | \(\ln(1)= {{c1:: 0}}\) |
\(\ln(1)= {{c1:: 0::\text{Number} }}\) |
Note 4: ETH::1. Semester::A&D
Deck: ETH::1. Semester::A&D
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
kXVME,u35.
Before
Front
Merge Sort space Complexity?
Back
Merge Sort space Complexity?
\(O(n)\)
After
Front
What's the space complexity of merge sort?
Back
What's the space complexity of merge sort?
\(O(n)\)
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | What's the space complexity of merge sort? |
Note 5: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
Bx0~E*k+P5
Before
Front
a != 0 && b / a == 3 evaluates to ???
Back
a != 0 && b / a == 3 evaluates to ???
Works fine, since if a == 0, it shortcircuits and simply returns false.
After
Front
Does this code snippet work?
a != 0 && b / a == 3
Back
Does this code snippet work?
a != 0 && b / a == 3
Yes, since if a == 0, it shortcircuits and simply returns false.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | <div><b>a != 0 && b / a == 3</b> |
<div><b>Does this code snippet work?</b></div><div><b><br></b></div><div><b>a != 0 && b / a == 3</b></div> |
| Back | Yes, since if <b>a == 0, </b>it shortcircuits and simply returns false. |
Note 6: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
E_rcts7/^g
Before
Front
while (i < n) {
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
Back
while (i < n) {
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
i <= n (the equality holds as we execute + 1 after the final execution)In general: a x < n becomes x <= n and x <= n becomes x <= n + 1!
After
Front
while (i < n) {
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
Back
while (i < n) {
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
result = result * k;
i = i + 1;
}
For the loop invariant, what bounds hold for i?
i <= n (the equality holds as we execute + 1 after the final execution)In general: x < n becomes x <= n and x <= n becomes x <= n + 1
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Back | <div><code>i <= n</code> (the equality holds as we execute <code>+ 1</code> after the final execution)<br><br><div>In general: |
<div><code>i <= n</code> (the equality holds as we execute <code>+ 1</code> after the final execution)<br><br><div>In general: x < n becomes x <= n and x <= n becomes x <= n + 1</div></div> |
Note 7: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
J)-A!rQ/Od
Before
Front
int[][] b = new int[3][0]int[] c = new int[3] b[0] = c
does this compile / runtime?Back
int[][] b = new int[3][0]int[] c = new int[3] b[0] = c
does this compile / runtime?Yes, it works fine as we just set the pointer of b[0] to c. Java does not typecheck array dimensions.
After
Front
int[][] b = new int[3][0]int[] c = new int[3] b[0] = c
Is this fine?
Back
int[][] b = new int[3][0]int[] c = new int[3] b[0] = c
Is this fine?
Yes, it works fine as we just set the pointer of b[0] to c. Java does not typecheck array dimensions.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | <code>int[][] b = new int[3][0]</code><br><code>int[] c = new int[3]</code> <br> <code>b[0] = c<br></code> |
<code>int[][] b = new int[3][0]</code><br><code>int[] c = new int[3]</code> <br> <code>b[0] = c<br></code><br>Is this fine? |
Note 8: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
MlNjJv:07k
Before
Front
String s1 = "test";
String s2 = "test";
s1 == s2 returns?
String s2 = "test";
s1 == s2 returns?
Back
String s1 = "test";
String s2 = "test";
s1 == s2 returns?
String s2 = "test";
s1 == s2 returns?
false, as we compare references. To compare strings we should use .equals()
After
Front
String s1 = "test";
String s2 = "test";
s1 == s2 returns?
String s2 = "test";
s1 == s2 returns?
Back
String s1 = "test";
String s2 = "test";
s1 == s2 returns?
String s2 = "test";
s1 == s2 returns?
Usually false, as we compare references. To compare strings we should use .equals().
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Back | false, as we compare references. To compare strings we should use <b>.equals()</b> | Usually false, as we compare references. To compare strings we should use <b>.equals().</b> |
Note 9: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Image Occlusion-73a2c
GUID:
modified
Note Type: Image Occlusion-73a2c
GUID:
gef_5DD5?n
Before
Front
Back
After
Front
Back
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Occlusion | {{c |
{{c2::image-occlusion:rect:left=.1151:top=.2639:width=.8709:height=.3659}}<br>{{c3::image-occlusion:rect:left=.0974:top=.7498:width=.7647:height=.2279}}<br>{{c1::image-occlusion:rect:left=.1151:top=.018:width=.6997:height=.126}}<br> |
Note 10: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID:
modified
Note Type: Horvath Cloze
GUID:
io,]_+ZcUp
Before
Front
What is the result of:
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller also
}
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller also
}
Back
What is the result of:
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller also
}
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller also
}
After
Front
What is the result of:
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller as well
}
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller as well
}
Back
What is the result of:
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller as well
}
void test(Integer k) {
k = Integer.valueOf(1); This only changes it locally! (Shadowing)
//
k.value = 1; This changes the value for the caller as well
}
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Text | What is the result of:<br><br><b>void test(Integer k) {</b><br> <b>k = Integer.valueOf(1); </b>{{c1:: This only changes it locally! (Shadowing)}}<br>//<br> <b>k.value = 1; </b>{{c1:: This changes the value for the caller a |
What is the result of:<br><br><b>void test(Integer k) {</b><br> <b>k = Integer.valueOf(1); </b>{{c1:: This only changes it locally! (Shadowing)}}<br>//<br> <b>k.value = 1; </b>{{c1:: This changes the value for the caller as well}}<br><b>}</b> |
Note 11: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
q|N{Bb]-?+
Before
Front
// {P}
if (a) {
S1;
} else {
S2;
}
// {Q}
How to find the precondition?Back
// {P}
if (a) {
S1;
} else {
S2;
}
// {Q}
How to find the precondition?Muss man zwei Fälle checken:
- \(P \land a \implies Q\) when S1; is executed.
- \(P \land \lnot a \implies Q\) when S2; is executed.
a && precondition1 OR !a && precondition2After
Front
// {P}
if (a) {
S1;
} else {
S2;
}
// {Q}
How can the precondition be found?Back
// {P}
if (a) {
S1;
} else {
S2;
}
// {Q}
How can the precondition be found?Man muss zwei Fälle checken:
- \(P \land a \implies Q\) when S1; is executed.
- \(P \land \lnot a \implies Q\) when S2; is executed.
a && precondition1 OR !a && precondition2Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | <pre><code>// {P}
if (a) {
S1;
} else {
S2;
}
// {Q} |
<pre><code>// {P} if (a) { S1; } else { S2; } // {Q}</code> </pre>How can the precondition be found? |
| Back | M |
Man muss zwei Fälle checken:<br><ul><li>\(P \land a \implies Q\) when S1; is executed.</li><li>\(P \land \lnot a \implies Q\) when S2; is executed. </li></ul>Dann kann man mit einem <b>||</b> beide Fälle in der Precondition verbinden: <code>a && precondition1</code> OR <code>!a && precondition2</code> |
Note 12: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
t=MANr.EfE
Before
Front
WP { }
PC { true }
the WP is .
PC { true }
the WP is .
Back
WP { }
PC { true }
the WP is .
PC { true }
the WP is .
Everything implies true and true implies true.
After
Front
What is the weakest precondition for an empty program with postcondition
true?Back
What is the weakest precondition for an empty program with postcondition
true?true.
Everything implies true and true implies true.
Everything implies true and true implies true.
Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Front | <div>What is the weakest precondition for an empty program with postcondition <code>true</code>?</div> <div><strong></strong></div> | |
| Back | Everything implies true and true implies true. | true.<br><br>Everything implies true and true implies true. |
Note 13: ETH::1. Semester::EProg
Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID:
modified
Note Type: Horvath Classic
GUID:
tja~6C@vsv
Before
Front
Does Java enforce array dimensions using type- or runtime-checks?
Back
Does Java enforce array dimensions using type- or runtime-checks?
No.
int[][] b = new int[3][0] int[] c = new int[3] b[0] = c
is fineAfter
Front
Does Java enforce array dimensions using type- or runtime-checks?
Back
Does Java enforce array dimensions using type- or runtime-checks?
No, this is fine:
int[][] b = new int[3][0];int[] c = new int[3]; b[0] = c;Field-by-field Comparison
| Field | Before | After |
|---|---|---|
| Back | No |
No, this is fine:<br><br><code>int[][] b = new int[3][0];</code><br><code>int[] c = new int[3];</code> <br> <code>b[0] = c;</code> |