Anki Deck Changes

Commit: ff049cb3 - add chap 4 and 5 cards eprog

Author: obrhubr <obrhubr@gmail.com>

Date: 2026-01-24T21:57:51+01:00

Changes: 14 note(s) changed (14 added, 0 modified, 0 deleted)

Note 1: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: DL*jz,QL[w
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::5._Logisches_Schliessen
WP { }
PC {false}
the WP is false

Back

ETH::1._Semester::EProg::5._Logisches_Schliessen
WP { }
PC {false}
the WP is false

As only false implies false.
Field-by-field Comparison
Field Before After
Text WP { }<br>PC {false}<br>the WP is {{c1::false}}
Extra As only false implies false.
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen

Note 2: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: E_A@gwOm;?
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::4._Sequences
Arrays has helper methods that make simple operations quicker:
  • Arrays.equals(a, b) to compare arrays
  •  Arrays.copyOf(arr, l) that returns a new copied array of length l
  • Sorting useing Arrays.sort(arr)
  • toString() and deepToString()

Back

ETH::1._Semester::EProg::4._Sequences
Arrays has helper methods that make simple operations quicker:
  • Arrays.equals(a, b) to compare arrays
  •  Arrays.copyOf(arr, l) that returns a new copied array of length l
  • Sorting useing Arrays.sort(arr)
  • toString() and deepToString()
Field-by-field Comparison
Field Before After
Text Arrays has helper methods that make simple operations quicker:<br><ul><li>{{c1:: <b>Arrays.equals(a, b)</b>&nbsp;to compare arrays}}<br></li><li>{{c2::&nbsp;<b>Arrays.copyOf(arr, l)</b>&nbsp;that returns a new copied array of length l}}</li><li>{{c3:: Sorting useing&nbsp;<b>Arrays.sort(arr)</b>}}</li><li>{{c4:: <b>toString()</b> and <b>deepToString()</b>}}</li></ul>
Tags: ETH::1._Semester::EProg::4._Sequences

Note 3: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID: E_rcts7/^g
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::5._Logisches_Schliessen
while (i < n) {
    result = result * k;
    i = i + 1;
}

For the loop invariant, what bounds hold for i?

Back

ETH::1._Semester::EProg::5._Logisches_Schliessen
while (i < n) {
    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!
Field-by-field Comparison
Field Before After
Front while (i &lt; n) {<br>&nbsp;&nbsp;&nbsp; result = result * k;<br>&nbsp;&nbsp;&nbsp; i = i + 1;<br>}<br><br>For the loop invariant, what bounds hold for i?
Back <div><code>i &lt;= n</code> (the equality holds as we execute <code>+ 1</code> after the final execution)<br><br><div>In general: a x &lt; n becomes x &lt;= n and x &lt;= n becomes x &lt;= n + 1!</div></div>
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen

Note 4: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: KhTp)`Z~|8
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::4._Sequences
Strings are immutable.

Back

ETH::1._Semester::EProg::4._Sequences
Strings are immutable.
Field-by-field Comparison
Field Before After
Text Strings are {{c1::<b>immutable</b>}}.
Tags: ETH::1._Semester::EProg::4._Sequences

Note 5: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID: MlNjJv:07k
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::4._Sequences
String s1 = "test";
String s2 = "test";
s1 == s2
returns?

Back

ETH::1._Semester::EProg::4._Sequences
String s1 = "test";
String s2 = "test";
s1 == s2
returns?

false, as we compare references. To compare strings we should use .equals()
Field-by-field Comparison
Field Before After
Front <b>String s1 = "test";<br>String s2 = "test";<br>s1 == s2</b> returns?
Back false, as we compare references. To compare strings we should use&nbsp;<b>.equals()</b>
Tags: ETH::1._Semester::EProg::4._Sequences

Note 6: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Image Occlusion-73a2c
GUID: gef_5DD5?n
added

Previous

Note did not exist

New Note

Front

image-occlusion:rect:left=.116:top=.0188:width=.6994:height=.1251:oi=1
image-occlusion:rect:left=.1147:top=.2666:width=.8699:height=.3679:oi=1
image-occlusion:rect:left=.0988:top=.7522:width=.7656:height=.2278:oi=1

Back

image-occlusion:rect:left=.116:top=.0188:width=.6994:height=.1251:oi=1
image-occlusion:rect:left=.1147:top=.2666:width=.8699:height=.3679:oi=1
image-occlusion:rect:left=.0988:top=.7522:width=.7656:height=.2278:oi=1
Field-by-field Comparison
Field Before After
Occlusion {{c1::image-occlusion:rect:left=.116:top=.0188:width=.6994:height=.1251:oi=1}}<br>{{c2::image-occlusion:rect:left=.1147:top=.2666:width=.8699:height=.3679:oi=1}}<br>{{c3::image-occlusion:rect:left=.0988:top=.7522:width=.7656:height=.2278:oi=1}}<br>
Image <img src="paste-f5e348f4bdf7f6aad53a5c374e67b394f92a5e44.jpg">
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen

Note 7: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: go.nl_(PCT
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::5._Logisches_Schliessen
The weakest precondition is true since true only implies true.

Back

ETH::1._Semester::EProg::5._Logisches_Schliessen
The weakest precondition is true since true only implies true.
Field-by-field Comparison
Field Before After
Text <div>The weakest precondition is {{c1::<code>true</code> since <code>true</code> only implies <code>true</code>}}.</div>
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen

Note 8: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: o2_oVlzFE[
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::4._Sequences
To compare two strings (or any non-primite type) we use  .equals() .

Back

ETH::1._Semester::EProg::4._Sequences
To compare two strings (or any non-primite type) we use  .equals() .

== compares the references, not the values.
Field-by-field Comparison
Field Before After
Text To compare two strings (or any non-primite type) we use {{c1::&nbsp;<b>.equals()</b>&nbsp;}}.
Extra == compares the references, not the values.
Tags: ETH::1._Semester::EProg::4._Sequences

Note 9: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: oWLG{z90=/
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::4._Sequences
To initialise an array directly we use int[] test = {{c1:: {1, 2, 3 ...};}}.

Back

ETH::1._Semester::EProg::4._Sequences
To initialise an array directly we use int[] test = {{c1:: {1, 2, 3 ...};}}.
Field-by-field Comparison
Field Before After
Text To initialise an array directly we use&nbsp;<b>int[] test =&nbsp;</b>{{c1:: {1, 2, 3 ...};}}.
Tags: ETH::1._Semester::EProg::4._Sequences

Note 10: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Classic
GUID: q|N{Bb]-?+
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::5._Logisches_Schliessen
// {P}
if (a) {
    S1;
} else {
    S2;
}
// {Q}

How to find the precondition?

Back

ETH::1._Semester::EProg::5._Logisches_Schliessen
// {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. 
Dann kann man mit einem || beide Fälle in der Precondition verbinden: a && precondition1 OR !a && precondition2
Field-by-field Comparison
Field Before After
Front <pre><code>// {P} if (a) { S1; } else { S2; } // {Q} </code> </pre>How to find the precondition?
Back Muss man zwei Fälle checken:<br><ul><li>\(P \land a \implies Q\)&nbsp;when S1; is executed.</li><li>\(P \land \lnot a \implies Q\)&nbsp;when S2; is executed.&nbsp;</li></ul>Dann kann man mit einem&nbsp;<b>||</b>&nbsp;beide Fälle in der Precondition verbinden:&nbsp;<code>a &amp;&amp; precondition1</code>&nbsp;OR&nbsp;<code>!a &amp;&amp; precondition2</code>
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen

Note 11: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: rd5%P7v`6L
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::5._Logisches_Schliessen
If P_1 implies P_2 then we can say that P_1 is a stronger precondition than P_2.

Back

ETH::1._Semester::EProg::5._Logisches_Schliessen
If P_1 implies P_2 then we can say that P_1 is a stronger precondition than P_2.
Field-by-field Comparison
Field Before After
Text <div>If <code>P_1</code>&nbsp;{{c1::implies}}&nbsp;<code>P_2</code> then we can say that <code>P_1</code> is {{c2::a stronger precondition}} than <code>P_2</code>.</div>
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen

Note 12: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: sC;1?2R2yM
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::4._Sequences
String s = "test"; to acces the first character we use s.charAt(0).

Back

ETH::1._Semester::EProg::4._Sequences
String s = "test"; to acces the first character we use s.charAt(0).
Field-by-field Comparison
Field Before After
Text String s = "test"; to acces the first character we use s{{c1::.charAt(0)}}.
Tags: ETH::1._Semester::EProg::4._Sequences

Note 13: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: t=MANr.EfE
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::5._Logisches_Schliessen
WP { }
PC { true }

the WP is true.

Back

ETH::1._Semester::EProg::5._Logisches_Schliessen
WP { }
PC { true }

the WP is true.

Everything implies true and true implies true.
Field-by-field Comparison
Field Before After
Text WP { }<br>PC { true }<br><br>the WP is {{c1:: true}}.
Extra Everything implies true and true implies true.
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen

Note 14: ETH::1. Semester::EProg

Deck: ETH::1. Semester::EProg
Note Type: Horvath Cloze
GUID: yNOkeWyJB3
added

Previous

Note did not exist

New Note

Front

ETH::1._Semester::EProg::5._Logisches_Schliessen
The strongest precondition is false since it implies everything.

Back

ETH::1._Semester::EProg::5._Logisches_Schliessen
The strongest precondition is false since it implies everything.
Field-by-field Comparison
Field Before After
Text <div>The strongest precondition is {{c1::<code>false&nbsp;</code>since it implies everything}}.</div>
Tags: ETH::1._Semester::EProg::5._Logisches_Schliessen
↑ Top