[CS@TUK] Questions and Answers - Recent questions and answers in # Mandatory Modules Bachelor
https://q2a.cs.uni-kl.de/qa/%23-mandatory-modules-bachelor
Powered by Question2AnswerAnswered: Convert to CNF
https://q2a.cs.uni-kl.de/2695/convert-to-cnf?show=2696#a2696
<p>First of all, <-> is associative, so that it does not matter for its semantics how we parse a sequence of this operator. According to the lecture, we defined this operator however as being left associative, so that we get the following expression with full use of brackets:</p><p> ((((a&d)<->b)<->c)|((a<->a)&!b))<->!(c<->(a->a))</p><p>A CNF obtained by the BDD of this formula is for instance the following one:</p><p> (!a|!b|!d) & (b|!c)</p><p>Before starting any computation, we first simplify the formula by replacing a<->a with true and propagating the boolean constants so that we get</p><p> ((((a&d)<->b)<->c)|!b)<->!c</p><p>Next, we make a Shannon decomposition: Starting with variable b (it has two occurrences and thus more than variable a), we get the following cofactors:</p><ul><li>b=0: !c</li><li>b=1: (a&d<->c)<->!c</li></ul><p>Thus, our formula is equivalent to (b -> (a&d<->c)<->!c) & (!b -> !c) which yields </p><p> (!b | ((a&d<->c)<->!c)) & (b|!c)</p><p>It remains to convert (a&d<->c)<->!c) to a CNF, so we make a Shannon decomposition with c:</p><ul><li>c=0: !(a&d)</li><li>c=1: !(a&d)</li></ul><p>That makes it simple, since the formula (a&d<->c)<->!c) is equivalent to !(a&d). Hence, we get the following formula:</p><p> (!b | !(a&d)) & (b|!c)</p><p>which has the following CNF:</p><p> (!b|!a|!d) & (b|!c)</p><div></div># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/2695/convert-to-cnf?show=2696#a2696Wed, 08 Jun 2022 07:51:41 +0000Answered: 2018 exam, 2 c)
https://q2a.cs.uni-kl.de/2283/2018-exam-2-c?show=2284#a2284
<p>For the 256 bytes, we need 8-bit addresses. The caches have 32 bytes and a block has 2 bytes, so that each cache has 16 blocks. </p><p>The direct mapped cache therefore needs 4 bits for set addresses so that a memory address a[7..0] is split into the tag a[7..5], the set address a[4..1] and the block offset a[0]. The set address a[4..1] is therefore computed as setAdr(adr) := (adr % 32) div 2. We therefore have</p><ul><li>setAdr(30) = 15</li><li>setAdr(31) = 15</li><li>setAdr(32) = 0</li><li>setAdr(33) = 0</li></ul><div>Hence, the set address is 0 and not 16 as you assumed. </div><div>For the 4-way set associative cache, we have 4 blocks in a set and therefore each set has 8 bytes, so that the cache has only 4 sets. To that end, we need 2 bits as set addresses, so that a memory address a[7..0] is split into the tag a[7..3], the set address a[2..1] and the block offset a[0]. The set address a[2..1] is therefore computed as setAdr(adr) := (adr % 8) div 2. </div><div></div><div></div># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/2283/2018-exam-2-c?show=2284#a2284Sun, 28 Mar 2021 17:01:36 +0000Answered: Abacus Cache Organisation: Word or Byte adressable?
https://q2a.cs.uni-kl.de/2262/abacus-cache-organisation-word-or-byte-adressable?show=2265#a2265
Abacus is using 16-bit data words, and is addressing a memory with such words also. Hence, each load/store refers to 2 bytes. Don't have doubts on this, unless it is stated otherwise in an exam problem. Some years ago, the version of Abacus of that time was byte-addressed like MIPS and that leads now to some confusions when looking at older exercises.<br />
<br />
To avoid this, I have reworked that exam problem completely so that the same computations that were necessary are now to be done for the current version of Abacus. The program used now in the exam also runs in the simulator so that you can verify the given solution.<br />
<br />
I hope this helps!# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/2262/abacus-cache-organisation-word-or-byte-adressable?show=2265#a2265Sat, 27 Mar 2021 17:20:23 +0000Answered: 17 WS Aufgabe 4 e
https://q2a.cs.uni-kl.de/2259/17-ws-aufgabe-4-e?show=2260#a2260
This is one of the strengths of deterministic parsing. There is unique parse tree that is generated by the parse table for a LL or LR grammar regardless whether that word is accepted or not. The exam problem you are considering is asking for that derivation/parse tree, and the final result whether it was accepting or not.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/2259/17-ws-aufgabe-4-e?show=2260#a2260Sat, 27 Mar 2021 08:52:39 +0000Answered: TAC read and write with arrays
https://q2a.cs.uni-kl.de/2256/tac-read-and-write-with-arrays?show=2258#a2258
Yes, that was a kind of a discussion for a while. On the one hand, you can argue that arrays are constants since a statement y[x1] = x2 is mapped to a store instruction sti x2,x1,y where y is a constant and thus only x1 and x2 are read and no variable is written. <br />
<br />
On the other hand, from the viewpoint of program analysis, you may argue that y[x1] = x2 is updating the array y if you consider y not just as a base address (as done in the C programming language) and instead consider the value of variable y as being the entire array (as done in the F# programming language for instance).<br />
<br />
So, dealing with the array is somehow a matter of taste. It does also not matter since we use that information for the dataflow analysis and that in turn is used for register allocation, and we never assign an array variable to a register (since we map array accesses to load/store instructions with the base address of y as a constant).# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/2256/tac-read-and-write-with-arrays?show=2258#a2258Fri, 26 Mar 2021 17:40:09 +0000Answered: rosy Sheet 4 ex. 2
https://q2a.cs.uni-kl.de/2225/rosy-sheet-4-ex-2?show=2229#a2229
<p>Well, you need to understand what the program does and in case of the program you mention, there is no other way that checking step by step what the content of the memory, the cache, and the registers is. Without the simulator that is quite some work, of course.</p><p>We have first executed some code such that reg[i]=i holds. Then, we execute the following:</p><pre><span style="font-size:14px"> sti $1,$0,0 // mem[0] := 1
sti $2,$0,1 // mem[1] := 2
ldi $2,$0,1 // reg[2] := mem[1] = 2
sti $3,$0,2 // mem[2] := 3
sti $4,$0,3 // mem[3] := 4
ldi $2,$0,1 // reg[2] := mem[1] = 2
sti $5,$0,7 // mem[7] := 5
sti $6,$0,8 // mem[8] := 6
sti $7,$0,9 // mem[9] := 7
ldi $2,$0,1 // reg[2] := mem[1] = 2</span></pre><p>We have a cache with 8 bytes, 2 bytes, i.e., one memory word, in a block and we use direct mapping. Hence, a memory address m is split into its cache address adr(m) = m mod 4 and its tag tag(m) = m div 4. This gives the following execution with memory transactions:</p><pre><span style="font-size:14px"> sti $1,$0,0 // mem[0] := 1 cache[0] := mem[0]
sti $2,$0,1 // mem[1] := 2 cache[1] := mem[1]
ldi $2,$0,1 // reg[2] := mem[1] = 2
sti $3,$0,2 // mem[2] := 3 cache[2] := mem[2]
sti $4,$0,3 // mem[3] := 4 cache[3] := mem[3]
ldi $2,$0,1 // reg[2] := mem[1] = 2
sti $5,$0,7 // mem[7] := 5 cache[3] := mem[7]; mem[3] := cache[3]
sti $6,$0,8 // mem[8] := 6 cache[0] := mem[8]; mem[0] := cache[0]
sti $7,$0,9 // mem[9] := 7 cache[1] := mem[9]; mem[1] := cache[1]
ldi $2,$0,1 // reg[2] := mem[1] = 2 cache[1] := mem[1]; mem[9] := cache[1]</span>
</pre><p>Note that the following memory addresses refer to the same cache address:</p><ul><li>0,4,8,12</li><li>1,5,9,13</li><li>2,6,10,14</li><li>3,7,11,15</li></ul><div>After each step, you need to remember the content of the cache, i.e., which memory block is currently at which address in the cache to find out whether there is a hit or a miss and which memory transaction is required. In particular, the last instruction is a miss since at that point of time, there is mem[9] at cache address 1 and we want to load address 1 which is also mapped to the same cache address. Hence, we first have to write back cache address 1 before loading mem[1] into cache[1].</div># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/2225/rosy-sheet-4-ex-2?show=2229#a2229Tue, 23 Mar 2021 19:28:04 +0000Answered: generator matrix
https://q2a.cs.uni-kl.de/1852/generator-matrix?show=1856#a1856
So far we never had exam problem about linear codes, but that does not mean that it is unimportant. I would say that a generator matrix should be given, and you should be able to encode and decode words with it. You may even assume a linear code that is separated so that the construction of the control matrix would be simple. it is then not much more than matrix multiplication, right?# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1852/generator-matrix?show=1856#a1856Sun, 23 Aug 2020 18:15:03 +0000Answered: SR flipflop logic minimization
https://q2a.cs.uni-kl.de/1854/sr-flipflop-logic-minimization?show=1855#a1855
<p>To keep it short: That will be no problem.</p><p>Side story: There are many rumors about SR-Flipflops which are not true. Consider a typical implementation by two NOR gates:</p><pre> next(p) = !(s | q)
next(q) = !(r | p)</pre><p>This leads to the following cases for the four possible inputs if these are kept stable:</p><ol><li>s=0 & r=0 : (next(p) = !q) & (next(q) = !p)</li><li>s=0 & r=1 : (next(p) = !q) & (next(q) = 0) and thus (p =1) & (q = 0) after two steps</li><li>s=1 & r=0 : (next(p) = 0) & (next(q) = !p) and thus (p =0) & (q = 1) after two steps</li><li>s=1 & r=1 : (next(p) = 0) & (next(q) = 0)</li></ol><p>Hence, you can see that s=1&r=1 do not lead to unstable outputs as often stated, but they violate the invariant that we want that q=!p. That is established by one of the inputs s=0&r=1 or s=1&r=0 and kept invariant by s=0&r=0. However, if we would have once the input s=1&r=1 which makes p=q=0, then the input s=0&r=0 would lead to an unstable state where p and q will oscillate. </p><p>You can look at is also from the perspective of the states</p><ol><li>p=0 & q=0 : (next(p) = !s) & (next(q) = !r), i.e. all four states are reachable from here</li><li>p=0 & q=1 : (next(p) = 0) & (next(q) = !r), i.e. with r=1 we switch to p=q=0 and otherwise remain in p=0 & q=1</li><li>p=1 & q=0 : (next(p) = !s) & (next(q) = 0), i.e. with s=1 we switch to p=q=0 and otherwise remain in p=1 & q=0</li><li>p=1 & q=1 : (next(p) = 0) & (next(q) = 0), i.e. we switch to p=q=0</li></ol><div><img alt="" src="https://q2a.cs.uni-kl.de/?qa=blob&qa_blobid=8018716056139149349" style="height:144px; width:300px"></div><div></div><div>As you can see, it is unavoidable to go through state p=q=0.</div><div></div><div>Having written way too much, let me emphasize here finally, that all of this is not relevant for the exam tomorrow. I don't want to create the impression that this is maybe something you should look at in detail. Please don't waste your time!</div><div></div># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1854/sr-flipflop-logic-minimization?show=1855#a1855Sun, 23 Aug 2020 18:10:42 +0000Answered: CNF/DNF or CCNF/CDNF
https://q2a.cs.uni-kl.de/1850/cnf-dnf-or-ccnf-cdnf?show=1851#a1851
If the exercise asks for CNF / DNF only, then the canonical-CNF / -DNF as well as the minial-CNF / -DNF and anything in between is ok.<br />
<br />
CNF / DNF only means that we need a conjunction of disjunctions of literals / a disjunction of conjunction of literals respectively, but size does not matter for that.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1850/cnf-dnf-or-ccnf-cdnf?show=1851#a1851Sun, 23 Aug 2020 17:00:21 +0000Answered: Huffman Coding ws14 ex.1g)
https://q2a.cs.uni-kl.de/1844/huffman-coding-ws14-ex-1g?show=1845#a1845
There is more than one correct solution. In the example, we have probabilities (E,0.5);(O,0.125);(S,0.125);(U,0.10);(L,0.05);(N,0.05);(G,0.05) and Huffman encoding is based on a sorting of the letters according to their probabilities. As there are some letters with the same probabilities, you can sort differently and this way you get different codes. Their average number of bits per symbol should however be the same, even though for certain symbols you will have different number of bits. For example, for L,N,G two will have five bits and one of them just four, which one does not matter for the average number of bits per symbol, but of course for the particular encoding it matters.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1844/huffman-coding-ws14-ex-1g?show=1845#a1845Sun, 23 Aug 2020 15:32:51 +0000Answered: B Complement Multiplication
https://q2a.cs.uni-kl.de/1828/b-complement-multiplication?show=1832#a1832
<p>I ran the program IntMultCRACRA with your inputs <7306>12 * <A0A2>12 and got the following partial products that have to be summed up to obtain the shown product:</p><pre> B 0 5 1 0 // pp[0][4..0]
B B 0 5 1 // pp[1][4..0]
B 6 1 6 B // pp[2][4..0]
0 9 1 A 8 // pp[3][4..0]
-------------------------------
0 9 1 A 8 B 1 0 // p[7..0] </pre><p>Computation of the partial products:</p><pre> <7306>12 * A = <B,0,5,1,0>12
<7306>12 * 0 + <B,0,5,1>12 = <B,B,0,5,1>12
<7306>12 * A + <B,B,0,5>12 = <B,6,1,6,B>12
<7306>12 * 2 + <B,6,1,6>12 = <0,9,1,A,8>12
</pre><p>About the red rectangle: You have to apply function alpha when you reach the most significant digits, i.e., in your red rectangle where we have i=1 and j=3=N-1, you have to compute the following</p><pre> sm = xin * yin + pin + cin
= x[1] * alpha(y[3]) + alpha(pp[0][4]) + cp[1][2]
= 0 * alpha(7) + alpha(B) + 0
= 0 * alpha(7) + alpha(B)
= (11<(12/2) ? +x : +11-12)
= +11-12
= -1
</pre><p>and with this, you obtain</p><pre> cp[1][3] = -1
pp[1][3] = 11
pp[1][4] = gamma(-1) = 11
</pre><p>About the green rectangle: Here we have i=3=M-1 and j=3=N-1, and we therefore compute</p><pre> sm = xin * yin + pin + cin
= alpha(x[3]) * alpha(y[3]) + alpha(pp[2][4]) + cp[3][2]
= alpha(7) * alpha(A) + alpha(B) + 0
= alpha(7) * alpha(A) + alpha(B) + 0
= -5 * -2 + -1 + 0
= 10 + -1 + 0
= 9
</pre><p>and with this, you obtain</p><pre> cp[3][3] = 0
pp[3][3] = 9
pp[3][4] = gamma(0) = 0
</pre><p>recall </p><pre> alpha(x) = (x<(Base/2) ? +x : +x-Base);
gamma(y) = (y<0 ? y+Base : y);</pre><p></p><p>Does this help?</p><p></p><p></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1828/b-complement-multiplication?show=1832#a1832Sun, 23 Aug 2020 13:45:41 +0000Answered: Rounding methods
https://q2a.cs.uni-kl.de/1826/rounding-methods?show=1827#a1827
<p>I don't see a mistake in the slides, let's check some examples:</p><ul><li>ceil(1.0-0.5) = ceil(0.5) = 1.0</li><li>ceil(1.4-0.5) = ceil(0.9) = 1.0</li><li>ceil(1.5-0.5) = ceil(1.0) = 1.0</li><li>ceil(1.6-0.5) = ceil(1.1) = 2.0</li><li>ceil(2.0-0.5) = ceil(1.5) = 2.0</li></ul><div>About cornercases: these are the numbers which are exactly in between two integers like x=1.5 (and not x=2.0). For those numbers n+0.5, we obtain ceil(n+0.5-0.5) = ceil(n) = n which means that we are rounding downwards, right?</div># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1826/rounding-methods?show=1827#a1827Sun, 23 Aug 2020 11:57:30 +0000Answered: DNF ex.4 ws17
https://q2a.cs.uni-kl.de/1820/dnf-ex-4-ws17?show=1821#a1821
<p>I think both is correct, note the the DNF is not a canonical normal form without further restrictions. You can verify the following equivalences:</p><ul><li>((a->b) ∧ (c∨a∨¬b)) <-> (¬a∧¬b ∨ a∧b ∨ ¬a∧c)</li><li>((a->b) ∧ (c∨a∨¬b)) <-> (¬a∧¬b ∨ ¬a∧b∧c ∨ a∧b)</li></ul><p>It is a matter of logic minimization. The function has even two minimal DNFs which are</p><ul style="box-sizing:border-box; font-family:OpenSans,Arial,sans-serif; font-size:14.000000953674316px; list-style-position:outside; margin-bottom:10px; margin-top:0px; padding-left:1.2em; padding-right:0px"><li style="box-sizing: border-box;">!a&!b|a&b|b&c</li><li style="box-sizing: border-box;">!a&!b|a&b|!a&c</li></ul># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1820/dnf-ex-4-ws17?show=1821#a1821Sun, 23 Aug 2020 10:51:29 +0000Answered: Floating point conversion
https://q2a.cs.uni-kl.de/1804/floating-point-conversion?show=1805#a1805
<p>I think the best way to do this is as follows which is without remembering many complicated formulas:</p><ol><li>Normalize the given number in that you haven/double it until the mantissa is between 1 and 2 while maintaining a product with a power of 2. Example: 0.2 = 0.2*2^0 = 0.4*2^{-1} = 0.8*2^{-2} = 1.6*2^{-3}</li><li>Convert the mantissa to radix 2: 1.6 = 1 + 1/2 + 1/16 + 1/32 + epsilon, i.e., <span style="color:#2980b9"><strong>1</strong><span style="font-family:Menlo,Monaco,Consolas,"Courier New",monospace; font-size:13px">.</span><strong>1001</strong></span><strong><span style="color:#e74c3c">1</span> + <span style="color:#27ae60">eps;</span></strong> if you need four bits, compute five here (which is the additional red one called the rounding bit).</li><li>Consider the two representable numbers less and greater than the given number; in the example, these are 1.1001_2 * 2^{-3} and 1.1010_2 * 2^{-3}. Which is the nearest number? This is easily seen as follows: if eps=0, then and the red digit is 1, we are exactly in the middle between two representable numbers, otherwise a red 1 tend to the upper number, and 0 to the lower one. Tie breaking is needed in case of the middle case which is done according to the rounding modes.</li><li>Rest depends on the rounding mode and whether you have a special case (denormal number, overflow, etc). </li></ol><p>Does this help? Read also the answer to <a href="https://q2a.cs.uni-kl.de/1697/conversion-to-resyfloat-if-x-1" rel="nofollow">https://q2a.cs.uni-kl.de/1697/conversion-to-resyfloat-if-x-1</a></p><p></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1804/floating-point-conversion?show=1805#a1805Sat, 22 Aug 2020 20:27:34 +0000Answered: FSM Regulations in the exam
https://q2a.cs.uni-kl.de/1798/fsm-regulations-in-the-exam?show=1801#a1801
I am not sure what you mean with zero/null states (Müllzustände). Are these unreachable states, or states from where we cannot reach the final states? If you mean that, the answer depends on what the exercise is about. If you have to have a deterministic automaton, you probably need these states to maintain the determinism (or you have to minimize the automaton since these states are useless). Otherwise, it may be okay to drop them.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1798/fsm-regulations-in-the-exam?show=1801#a1801Sat, 22 Aug 2020 19:07:28 +0000Answered: BDD: ws17 exercise 5 mistake + apply algorithm
https://q2a.cs.uni-kl.de/1789/bdd-ws17-exercise-5-mistake-apply-algorithm?show=1799#a1799
<p>So, I guess the first question is already answered if it was a wrong use of the operator precedences: XOR binds stronger than implication. If you have doubts about something like this, please ask in exams.</p><p>For problem 5c, one should compute the conjunction of BDDs for ((a∧¬b)∨c) and a∧b∧¬d ∨ ¬a which should produce the following BDDs:</p><p><img alt="" src="https://q2a.cs.uni-kl.de/?qa=blob&qa_blobid=9397875491005437398" style="height:277px; width:150px"> & <img alt="" src="https://q2a.cs.uni-kl.de/?qa=blob&qa_blobid=5250578132415861464" style="height:262px; width:150px"> = <img alt="" src="https://q2a.cs.uni-kl.de/?qa=blob&qa_blobid=7634766164069946370" style="height:272px; width:150px"></p><p>Note that the ordering is given and therefore c must occur before d on the paths.</p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1789/bdd-ws17-exercise-5-mistake-apply-algorithm?show=1799#a1799Sat, 22 Aug 2020 18:59:41 +0000Answered: Floating Point Arithmetic
https://q2a.cs.uni-kl.de/1743/floating-point-arithmetic?show=1745#a1745
For floating point numbers, you mainly need to be able to convert given numbers from and to floating point format. Performing arithmetic operations on floating point numbers is quite involved, and we usually don't do that in the exam. You should however know how that works in principle, i.e., that we need to adapt the exponents for addition/subtraction, and so on. Performing that in detail is however quite involved since rounding is required at the right steps etc. Bytheway, hardware implementations for the "full" IEEE754 standard are still not everywhere used since it is so complicated.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1743/floating-point-arithmetic?show=1745#a1745Fri, 21 Aug 2020 13:42:30 +0000Answered: Korrekter Rechenweg
https://q2a.cs.uni-kl.de/1725/korrekter-rechenweg?show=1726#a1726
Ja, das ist okay.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1725/korrekter-rechenweg?show=1726#a1726Fri, 21 Aug 2020 07:29:24 +0000Answered: What is a BDD(0)?
https://q2a.cs.uni-kl.de/1704/what-is-a-bdd-0?show=1705#a1705
It refers to the False/True leaves. BDD(0) = False-leaf. BDD(1) = True-leaf.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1704/what-is-a-bdd-0?show=1705#a1705Thu, 20 Aug 2020 17:20:16 +0000Answered: Conversion to ReSyFloat if |x|<1
https://q2a.cs.uni-kl.de/1697/conversion-to-resyfloat-if-x-1?show=1702#a1702
<p>Let's convert 0.2 to a floating point number with 4 bits for the mantissa and three bits for the exponent. First, let's consider what the teaching tool does. </p><p>To describe the input, we have to specify the number as a quotient of integers, e.g., 2/10. The tool first translates these two numbers to radix-2 numbers and reads it as <10>_2 / <1010>_2. It realizes that it needs to scale the division by a factor of 2^7, i.e., to compute +<100000000>_2 / <1010>_2 * 2^{-7} to have sufficiently many digits for the mantissa when doing an integer division. The result of this integer division is now </p><pre>+<1.<span style="color:#2980b9">100</span><span style="color:#e74c3c">1</span><span style="color:#16a085">...0/1...</span>>_2 * 2^{-3}</pre><p>The meaning of this is as follows: the mantissa is normalized (as you can see it starts with a 1 left of the decimal point). The next three digits given in blue color will be our remaining bits for the mantissa. The next bit given in red color is called the <em>rounding bit</em>; it would be the next bit after our mantissa, and finally the 0/1 given in green color will tell us whether there are futher 1 digits after this one (this is known by the integer division +<100000000>_2 / <1010>_2 by checking the remainder). Sometimes people call the green part the sticky bit in that they provide a bit which is 1 if there are further 1 bits and 0 otherwise.</p><p>Now, we either have to choose one of the representable numbers +<1.100>_2 * 2^{-3} or +<1.101>_2 * 2^{-3} since our actual number 0.2 = +<1.1001...0/1...>_2 * 2^{-3} cannot be precisely represented. Which one of the two is chosen depends on the rounding mode, and there we have to consider three cases:</p><ol><li>In case the rounding bit would be 0, then the number would be closer to +<1.100>_2 * 2{-3}. </li><li>However, as the rounding bit is 1, and there are further 1-bits after this (the green ones), our number is closer to +<1.101>_2 * 2{-3}. </li><li>There could also be the third case, where the rounding bit is 1, and there are no further green bits on the right. In that case, the number would be right in the middle of the representable numbers +<1.100>_2 * 2{-3} and +<1.101>_2 * 2{-3}.</li></ol><p>The table that follows in the output of the teaching tool tells you the numbers chosen for the different rounding modes. </p><p>If we would like to use a hidden bit, we should specify one further bit for the teaching tool, and the omit the leading 1 of the mantissa as the hidden bit. </p><p>When are denormal numbers used? They are used when the exponent becomes zero. In that case, we cannot reduce the exponent further to scale the mantissa, and we have to live with a mantissa that is not normalized. Recall that normalizing means that the mantissa is between 1 and 2, i.e., in binary 1.xxxxx. If that cannot be achieved with the exponents that we have, you need to represent the number as a denormal number (or it is an overflow).</p><p>Looking at the slides 23-26, you need to compute it as follows: First, normalize the number, i.e., represent it as M*2^{E} such that 1≤M<2 holds. In our case, we get</p><pre> 0.2 = 0.4 * 2^{-1} = 0.8 * 2^{-2} = 1.6 * 2^{-3}</pre><p>So, we have M = 1.6 and E = -3. With 3 bits for the exponent, we obtain the offet beta .= (2^{3}-1)/2 = 3. Hence, E+beta = -3+3 = 0, and the exponent that we should use is 0, so we will have a denormalize number (indicated by exponent 0).</p><p>Now note that 1.6 = 1 + 1/2 + 1/16 + ... which gives us the same information as mentioned above, i.e. </p><pre>+<1.<span style="color:#2980b9">100</span><span style="color:#e74c3c">1</span><span style="color:#16a085">...0/1...</span>>_2 * 2^{-3}</pre><div>The rest can be explained as before.</div><p>Does it help?</p><p></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1697/conversion-to-resyfloat-if-x-1?show=1702#a1702Thu, 20 Aug 2020 17:02:26 +0000Answered: Compose Algorithm ITE
https://q2a.cs.uni-kl.de/1683/compose-algorithm-ite?show=1686#a1686
<p>Yes, you can use the ITE algorithm with three BDDs as operands. That is the core problem solved by the ITE algorithm. Once you have figured out the three BDDs which are the operands of the ITE algorithm, then you simple follow the steps of the ITE algorithm:</p><p><img alt="" src="https://q2a.cs.uni-kl.de/?qa=blob&qa_blobid=17470111341363177957" style="height:212px; width:450px"></p><p>Maybe I don't understand what your problem there is?</p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1683/compose-algorithm-ite?show=1686#a1686Thu, 20 Aug 2020 09:31:53 +0000Answered: Operator Base for XOR and AND
https://q2a.cs.uni-kl.de/1663/operator-base-for-xor-and-and?show=1666#a1666
<p>¬a = a <span style="font-size:14px">⊕ 1 </span></p><p><span style="font-size:14px">Using other notation, </span><span style="font-size:14px">not a = a xor 1</span></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1663/operator-base-for-xor-and-and?show=1666#a1666Wed, 19 Aug 2020 10:16:58 +0000Answered: Question on exam WS17, 3b
https://q2a.cs.uni-kl.de/1629/question-on-exam-ws17-3b?show=1632#a1632
Yes, we do not carefully distinguish between overflow and NaN (IEEE 754 does that very carefully). You are right that the problem is rather an overflow, what the teaching tool wants to express is that this number cannot be represented.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1629/question-on-exam-ws17-3b?show=1632#a1632Tue, 18 Aug 2020 12:39:58 +0000Answered: Exist Algorithm
https://q2a.cs.uni-kl.de/1621/exist-algorithm?show=1626#a1626
<p>In general, boolean quantification is defined as follows:</p><ul><li>∃x. Phi := Phi[x<-0] ⋁ Phi[x<-1]</li><li>∀x. Phi := Phi[x<-0] ∧ Phi[x<-1]</li></ul><div>In case of existential quantification, it says that Phi holds for some variable assignment where we don't care about the value of x (whether it is either 0 or 1) in the sense that at lease of the values 0,1 for x will extend the variable assignment to satisfy Phi. In case of the universal quantification it says that there must be an assignment for the rest of the variables so that assigning both values x<-0 and value x<-1 (one at a time, of course) will both satisfy the formula.</div># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1621/exist-algorithm?show=1626#a1626Tue, 18 Aug 2020 10:41:43 +0000Answered: DNF determination
https://q2a.cs.uni-kl.de/1619/dnf-determination?show=1625#a1625
There are many ways: Truth tables are certainly one, but that one is always an exponential-size effort. Another approach is to compute a ROBDD, and then to enumerate the paths from the root node to the 1-leaf; each path is a conjunction of possibly negated variables and denotes a variable assignment. Using a disjunction of the paths gives you another DNF. And there is also the way to use Boolean algebra to rewrite a given formula to DNF which is also sometimes a fast solution. Yet another way is to compute the CNF of the negation, and to negate that again to make it a DNF.<br />
<br />
In general, there is no best way, it always depends on the given formulas.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1619/dnf-determination?show=1625#a1625Tue, 18 Aug 2020 10:36:14 +0000Answered: Compose Algorithm
https://q2a.cs.uni-kl.de/1571/compose-algorithm?show=1572#a1572
<p>There are again multiple steps happening at once. If we simply follow the algorithm, then the <strong>b</strong> node is <em>"pulled up"</em> and the Compose-Node goes down one level. Once phi is only <strong>True</strong> or <strong>False</strong> case 1 (from your question) applies.</p><p>Here we can see this directly, because <strong>a</strong> does not occur in phi. Therefore case 2 will never apply. We will simply go down recursively until finally case 1 applies. Intuitively: We want to replace <strong>a</strong>. <strong>a</strong> does not occur in phi. Therefore we leave phi as it is.</p><p>This is a shortcut that is easy to see for humans, and you are allowed to do that in the exam (but better write a comment next to it). The computer can't see that since it only goes through the tree node by node and does not have an <em>"overview"</em>.</p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1571/compose-algorithm?show=1572#a1572Mon, 17 Aug 2020 16:22:38 +0000Answered: Exist Algorithm
https://q2a.cs.uni-kl.de/1544/exist-algorithm?show=1546#a1546
You are right. On the left side, two steps are happening at once.<br />
<br />
We look at the left and right child of the left exists-node. We see c > b, and therefore we can remove c (c can not occur in the right child, since it's ordered). Now both children of the exists-node are b and we can apply the same case as on the right side.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1544/exist-algorithm?show=1546#a1546Mon, 17 Aug 2020 10:07:39 +0000Answered: Questions about exam exercises
https://q2a.cs.uni-kl.de/1537/questions-about-exam-exercises?show=1538#a1538
<p>Answers for the DiRa exam in SS20:</p><ol><li>If the output character is seen in the state, yes, since then that information is redundant. I guess that is what you have in mind. However, if the states would be called 0,1,2,... then some information would be missing, right?</li><li>Linear clause forms are of outmost importance for SAT solving; SAT solving is of outmost importance for verification; verification is of outmost importance for digital circuit design; so yes, it is required!</li><li>No, we exclude the case where the basis is an odd number. In general, it is possible to have odd numbers as bases, but then the algorithms sometimes need another special case. We exclude that since the bases used in circuit design are mostly powers of two and thus even numbers. </li><li>That is definitely no problem, and we even allow pocket calculators. However, because of that, be prepared that we might ask for a number conversion to base 7 which you don't find on pocket calculators. </li></ol><p></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1537/questions-about-exam-exercises?show=1538#a1538Sun, 16 Aug 2020 18:44:27 +0000Answered: Questions about exam
https://q2a.cs.uni-kl.de/1524/questions-about-exam?show=1525#a1525
Here are my answers:<br />
<br />
(1+2) You do not need all points to get a 1.0. You can see with the published grade table that at that time 90 points were required for the 1.0, and the exam had 125 points in total. So, you roughly need 75% of the points. <br />
<br />
(3) If we find adjacent cubes, i.e., cubes that only differ by exactly one variable, then their disjunction is equivalent to the infimum of these cubes. Both the disjunction and the infimum are commutative and associative operations, so C_(1,2,3,4) and C_(1,3,2,4) are the same and you just need to compute one. That is why for each column in the Quine table, you just need to scan the other cubes below it to compute new cubes for the next column.<br />
<br />
(4) Yes, the two columns are exchanged!<br />
<br />
(5) You mean the solutions of the exam in SS15. No, we have not made solutions for that, sorry.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1524/questions-about-exam?show=1525#a1525Sun, 16 Aug 2020 11:21:10 +0000Answered: Is a calculator allowed on the exam?
https://q2a.cs.uni-kl.de/1454/is-a-calculator-allowed-on-the-exam?show=1455#a1455
see <a href="https://q2a.cs.uni-kl.de/1429/can-we-use-a-calculator-for-the-dira-exam" rel="nofollow">https://q2a.cs.uni-kl.de/1429/can-we-use-a-calculator-for-the-dira-exam</a># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1454/is-a-calculator-allowed-on-the-exam?show=1455#a1455Fri, 14 Aug 2020 12:01:54 +0000Answered: Boolean Algebra proof SAT and VALID
https://q2a.cs.uni-kl.de/1237/boolean-algebra-proof-sat-and-valid?show=1245#a1245
<p>What about this solution:</p><pre> ((¬a ∨ a) ↔ (b ∨ a)) → (¬((¬a ∨ b) ∧ a) ↔ a ⊕ b)
= (1 ↔ (b ∨ a)) → (¬((¬a ∨ b) ∧ a) ↔ a ⊕ b)
= (b ∨ a) → ((¬((¬a ∨ b) ∧ a) ↔ a) ⊕ b)
= (b ∨ a) → ((¬((¬a ∨ b) ∧ a) ∧ a ∨ ((¬a ∨ b) ∧ a) ∧ ¬a) ⊕ b)
= (b ∨ a) → ((¬((¬1 ∨ b) ∧ 1) ∧ a ∨ ((¬0 ∨ b) ∧ 0) ∧ ¬a) ⊕ b)
= (b ∨ a) → ((¬b ∧ a) ⊕ b)
= (b ∨ a) → ((¬b ∧ a) ∧ ¬b ∨ ¬(¬b ∧ a) ∧ b)
= (b ∨ a) → ((1 ∧ a) ∧ ¬b ∨ ¬(¬1 ∧ a) ∧ b)
= (b ∨ a) → (a ∧ ¬b ∨ ¬0 ∧ b)
= (b ∨ a) → (a ∧ ¬b ∨ b)
= (b ∨ a) → (a ∨ b)
= ¬(b ∨ a) ∨ (a ∨ b)
= ¬(a ∨ b) ∨ (a ∨ b)
= 1</pre><p> </p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1237/boolean-algebra-proof-sat-and-valid?show=1245#a1245Mon, 03 Aug 2020 13:49:31 +0000Answered: wordlength arithmetic encoding
https://q2a.cs.uni-kl.de/1210/wordlength-arithmetic-encoding?show=1212#a1212
<p>Yes you are right. When we decode <em>0.66</em>, we first identify that in the start interval <em>[0.0,1.0]</em>, it belongs to <strong>B</strong>'s sub-interval <em>[0.6,0.8]</em> (see first line in figure). Then in the interval <em>[0.6,0.8]</em>, we identify that encoding <em>0.66</em> belongs to <strong>A</strong>'s sub-interval <em>[0.6,0.72]</em> (second line in figure). Then in the interval <em>[0.6,0.72]</em>, we narrow down <em>0.66</em> to <strong>A</strong>'s sub-interval <em>[0.6,0.672]</em> (third line in figure). Continuing similarly, in the interval <em>[0.6,0.672]</em>, encoding <em>0.66</em> belongs to <strong>C</strong>'s sub-interval <em>[0.6576,0.672]</em> (fourth line in figure). As you can see, we may continue decoding like this forever since the number <em>0.66</em> will always belong to one of the sub-intervals. </p><p><img alt="" src="https://q2a.cs.uni-kl.de/?qa=blob&qa_blobid=4431994567902197712" style="height:503px; width:550px"></p><p>It is therefore necessary to inform the decoder when to stop. This can be done in a few ways. One way would be to use a special symbol as end-of-data. For instance, if symbol <strong>C</strong> is used in the above example to indicate end-of-data, the decoded word would be <strong>BAAC</strong>. Another way would be to specify total number of symbols in the word. For instance, if total number of symbols is specified as <em>5</em> in the above example, then the decoded word would be <strong>BAACA</strong>. In this case, there would be a fifth line in the above figure indicating that in the interval <em>[0.6576,0.672]</em>, the encoding <em>0.66</em> belongs to <strong>A</strong>'s sub-interval <em>[0.6576,0.66624]</em>.</p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1210/wordlength-arithmetic-encoding?show=1212#a1212Sun, 26 Jul 2020 11:06:35 +0000Answered: DiRa last chapters Processor Architecture + MIPS
https://q2a.cs.uni-kl.de/1203/dira-last-chapters-processor-architecture-mips?show=1206#a1206
They are relevant for the exam, but maybe not the most important topics. They are also an outlook on the RoSy lecture where processor architecture and system software are in the focus. The two lectures are connected by using digital circuit design (which is the major focus of DiRa) for the design of processors. <br />
<br />
What is needed for the DiRa exam of this chapter? Well, we do not really discuss the micro architecture of processors, i.e., the circuit design, but just the macro architecture, which means the instruction set. You should therefore be able to read and write such programs. For the execution of these programs, we have the programmer's point of view which means that we assume that in each cycle, one instruction is executed. In reality, this is not the case, but that is the topic of RoSy.<br />
<br />
If such an exercise should be part of the exam, we will add a sheet of paper with all of the instructions. So, you don't have to remember them all, but it is recommended to have seen and understood them during the exam preparation. As said, the single-cycle execution of the instructions should then be sufficient.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1203/dira-last-chapters-processor-architecture-mips?show=1206#a1206Fri, 17 Jul 2020 10:02:12 +0000Answered: DiRa-Hazard
https://q2a.cs.uni-kl.de/1150/dira-hazard?show=1151#a1151
That chapter is not so important. You should know what hazards are and why they could be there, but last time the lecture was given, there wasn't enough time to go into the details. It would be now easy in the digital time to not count the time needed, but I would feel unfair to do this. Thus, let's decide to skip that chapter.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/1150/dira-hazard?show=1151#a1151Sat, 04 Jul 2020 08:49:36 +0000Answered: Exercise 4.1 Rounding Methods(1)
https://q2a.cs.uni-kl.de/848/exercise-4-1-rounding-methods-1?show=849#a849
<p>After scaling up by 2<sup>5</sup> we are left with the remainder 0.4375. It is less than 0.5 so we round down. If it was more than 0.5 we would round up. <em>"To nearest even"</em> only comes into play if we have exactly 0.5. This is why it's called a <em>tie-breaking</em> rule (0.5 is a tie between up and down).</p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/848/exercise-4-1-rounding-methods-1?show=849#a849Tue, 26 May 2020 19:36:47 +0000Answered: Exercise 4.3 Rounding Methods(1)
https://q2a.cs.uni-kl.de/845/exercise-4-3-rounding-methods-1?show=847#a847
<p>The exercise says <strong>radix-2</strong> number. Since it says <em>"to 5 digits"</em> and not <em>"to 5 digits after the point"</em> it does not matter whether or not it is a fixpoint number (note that radix numbers we used up until here are also just fixpoint numbers with their point right of the LSB).</p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/845/exercise-4-3-rounding-methods-1?show=847#a847Tue, 26 May 2020 16:36:16 +0000Answered: connection of entropy, minimum bits and coding length
https://q2a.cs.uni-kl.de/494/connection-of-entropy-minimum-bits-and-coding-length?show=496#a496
<p>Maybe my answer here is too long, but let me first clarify the context (since I think that it is required for understanding the final answer below): If we have any code that maps the letters σ_1,...,σ_n of an alphabet to code words (σ_1),...,(σ_n), then the length of a word α=a_1...a_k of length k where letter σ_i occurs n_i many times, i.e., n_i many of the a_1...a_k are letter σ_i, is </p><pre> |(α)| = sum(j=1..k) |(a_j)| = sum(i=1..n) n_i * |(σ_i)|
</pre><p>On average, we have P(σ_i) = n_i/k, since that is the meaning of average probability of a letter σ_i. Hence, we have </p><pre> |(α)| = k * sum(i=1..n) P(σ_i) * |(σ_i)|
</pre><p>To be independent of the length k of the word α, we therefore define the <span style="color:#e74c3c">weighted code size average Size(P,) </span>as</p><pre><span style="color:#e74c3c"> Size(P,) := sum(i=1..n) P(σ_i) * |(σ_i)|</span>
</pre><p>To have minimal size code words (in average), we obviously have to minimize Size(P,), i.e., we have to find an encoding where Size(P,) is as small as possible. </p><p><span style="color:#e74c3c">Shannon's source coding theorem gives us now a lower bound for Size(P,) with the entropy H(P,Sigma) defined as H(P,Sigma) := - sum(i=1..n) P(σ_i) * log_2(P(σ_i)). In particular, it states that </span></p><pre><span style="color:#e74c3c"> (1) H(P,Sigma) <= Size(P,)
(2) H(P,Sigma) = Size(P,) iff |(σ_i)| = -log_2(P(σ_i))</span>
</pre><p>You find the proof of this theorem on the slides. So, the weighted code size average Size(P,) cannot become less than the entropy H(P,Sigma), and the minimum H(P,Sigma) of Size(P,) is obtained with an encoding where |(σ_i)| = -log_2(P(σ_i)) holds. </p><p>Unfortunately, -log_2(P(σ_i)) is typically not an integer, so that we have to choose an integer nearby that real value. In that case, it can additionally be proved that </p><pre> H(P,Sigma) <= Size(P,) < H(P,Sigma) + 1
</pre><p>This was already one of your questions. With a good encoding of code words of integer size, we may not be able to reach the minimum <span style="white-space:pre-wrap">H(P,Sigma), but at least, we </span>can achieve a weighted code size average Size(P,) less than <span style="white-space:pre-wrap">H(P,Sigma) + 1.</span></p><p>Based on this theorem, we define the <span style="color:#e74c3c">"information Inf(σ_i)" of letter σ_i as Inf(σ_i) := -log_2(P(σ_i))</span> which is measured in bits. </p><p></p><p>Now, we come to your question: What do we learn from slides 34-36? The question is here, <span style="color:#e74c3c">which are worst-case alphabets for encoding, i.e., when do we have to choose longest encodings (σ_i)?</span> By Shannon's source coding theorem, that means that these alphabets will have a <span style="color:#e74c3c">maximal entropy</span>. So, how big can the entropy be for an alphabet Sigma with n letters? To that end, we considered the function</p><pre> h(x_1,...,x_n) := - sum(i=1..n) x_i * log_2(x_i)
</pre><p>and proved that this function has a maximum when x_i = 1/n holds. That means that <span style="color:#e74c3c">alphabets are worst cases for encoding when the probabilities are the same, i.e., P(σ_i) = 1/n for each letter σ_i</span>. In that worst case, we have</p><pre> Hmax = - sum(i=1..n) P(σ_i) * log_2(P(σ_i))
= - sum(i=1..n) 1/n * log_2(1/n)
= sum(i=1..n) 1/n * log_2(n)
= log_2(n)
</pre><p>Hence, the larger the entropy, i.e., the closer the P(σ_i)'s are to each other, the greater is the "surprise" to see a particular letter σ_i. In other words, the smaller the entropy, i.e., the more different the P(σ_i)'s are to each other, the smaller is the "surprise" to see the one or the other letter. This is clear, since in the latter case, we have letters σ_i of high probability, and we are not surprised to see them. So, the entropy (the information) is a measure for the surprise to see a particular message.</p><p>So, lesson learned: Shannon showed us that <span style="color:#e74c3c">there is a minimum for encoding and that minimum is the content of information in the data encoded</span>. No compression algorithm can reduce that further, and therefore it does not make much sense to compress an already compressed file. There is a minimum size given by its information content that we have to accept.</p><p>The worst case is for example, where you need to encode all numbers from 0,...,2^{32}-1 where each number has the same probability 2^{-32}. In that case, every code word requires -log_2(2^{-32}) = 32 bits and that is what you typically find in computers. Such encodings are discussed in the next chapter by radix-2 and 2-complement numbers.</p><p></p><p></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/494/connection-of-entropy-minimum-bits-and-coding-length?show=496#a496Fri, 01 May 2020 12:30:30 +0000Answered: How do I ask questions regarding „Digitaltechnik und Rechnerarchitektur“?
https://q2a.cs.uni-kl.de/477/questions-regarding-digitaltechnik-rechnerarchitektur?show=478#a478
I heard that there is now the new tag "dira" that should be used to tag questions for the mentioned course.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/477/questions-regarding-digitaltechnik-rechnerarchitektur?show=478#a478Mon, 27 Apr 2020 14:40:46 +0000Answered: Objekte und Klassen
https://q2a.cs.uni-kl.de/261/objekte-und-klassen?show=264#a264
Zu Frage 1:<br />
<br />
Ja, eine Klasse kann gleichzeitig ein oder mehrere Interface implementieren und eine Superklasse haben.<br />
<br />
Im Code fehlt ein Parameter beim Konstruktor von SpeicherGr und wenn ich das richtig sehe kompiliert er auch nicht.<br />
<br />
Zu Frage 2:<br />
<br />
- Sie haben den Punkt "Achten Sie dabei auf gute Kapselung" nicht beachtet. Im Allgemeinen ist es in Java eine gute Idee die Attribute private zu halten, um dann mit Methoden entscheiden zu können, wie der Zustand von außen verändert werden kann.<br />
<br />
- Das Attribut "speichergr" gibt es zweimal, da ist die Lösung oben besser. Außerdem wäre es sinnvoll, wenn der Typ Medium eine Methode hätte um den Speicherverbrauch zu bekommen.<br />
<br />
- Die Rechnung für Ebooks stimmt so nicht. Wenn man 0.75 Seiten pro Minute liest, dann sollte man für 75 Seiten 100 Minuten brauchen. Mit Ihrer Rechnung kommt man aber auf ca 94 Minuten.<br />
<br />
- Die Laufzeit wird als int gespeichert und nicht wie gefordert als double.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/261/objekte-und-klassen?show=264#a264Tue, 11 Sep 2018 10:40:41 +0000Answered: SS17_AK Lösung c)
https://q2a.cs.uni-kl.de/255/ss17_ak-l%C3%B6sung-c?show=257#a257
Die erste Fehlermeldung sagt, dass in Zeile 12 das Array "eingabe" und "erwartet" unterschiedliche Arrays sind. Die Methode assertEquals prüft nicht den Inhalt der Arrays. Dafür gibt es die Methode "assertArrayEquals". Alternativ kann man auch mit einer Schleife alle Einträge einzeln mit assertEquals vergleichen.<br />
<br />
Ein entsprechender Hinweis war auch auf Übungsblatt 5, Aufgabe 3, wo das Problem das erste mal auftrat.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/255/ss17_ak-l%C3%B6sung-c?show=257#a257Mon, 10 Sep 2018 08:43:46 +0000Answered: Verbesserung
https://q2a.cs.uni-kl.de/254/verbesserung?show=256#a256
<p>Es wäre denke ich gut, wenn Sie bei Folgefragen einen Link auf die vorherige Frage einfügen (<a href="https://q2a.cs.uni-kl.de/252/volle-punktzahl-array" rel="nofollow">https://q2a.cs.uni-kl.de/252/volle-punktzahl-array</a>)</p><blockquote><p>D.h. für swapMinMax sollte die if-Klausel (mit der Prüfung auf !(ar == null || ar.length == 0) als erste Zeile der Methode eingefügt werden -> Verhinderung zugreifen auf Array der Länge null</p></blockquote><p>Ja, noch einfacher wäre es am Anfang einmal den Randfall abzufangen und dann direkt die Methode zu verlassen:</p><pre>if (ar.length == 0) {
return;
}</pre><p>Zu Teil c): Es gibt keine statische Methode String.equals für den Vergleich von Strings. Daher kompiliert der Code nicht.</p><p>Es müsste entweder "Objects.equals(BuchstaInQ, keys[j])" heißen (mit "import java.util.Objects;" am Anfang der Datei) oder "keys[j].equals(BuchstaInQ)".</p><p>Bei der zweiten Variante ist zu beachten, dass der linke Ausdruck nicht null sein darf, was hier der Fall ist weil laut Aufgabenstellung kein Schlüssel im keys Array null ist.</p><p></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/254/verbesserung?show=256#a256Mon, 10 Sep 2018 08:29:09 +0000Answered: Volle Punktzahl Array
https://q2a.cs.uni-kl.de/252/volle-punktzahl-array?show=253#a253
1) Die Lösung ist korrekt<br />
<br />
Der Fall, dass null als Parameter übergeben wird muss nicht behandelt werden, das Leere Array aber schon.<br />
<br />
2)<br />
<br />
Ein Fehler: Hier sollte die Bedingung ar.length == 0 geprüft werden, bevor auf das Array zugegriffen wird, weil es sonst zu einer ArrayIndexOutOfBounds Exception kommen kann.<br />
<br />
3)<br />
<br />
2 Fehler:<br />
<br />
- Die Länge von res sollte zu Beginn der Länge von q entsprechen. Die Aufgabe schließt nicht aus, dass in q Einträge mehrmals vorkommen, d.h. das Array könnte mit values.length zu klein sein.<br />
<br />
- Um Strings zu vergleichen sollte die equals-Methode verwendet werden. Der Vergleich mit == vergleicht in Java nicht den Inhalt der Strings sondern nur, ob es sich um das gleiche String-Objekt handelt.<br />
<br />
<br />
Bezüglich Bepunktung: Vermutlich gäbe es für die 3 Fehler auch 3 Punkte Abzug von der maximalen Punktzahl.# Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/252/volle-punktzahl-array?show=253#a253Sat, 08 Sep 2018 10:45:05 +0000Answered: SE_1 AK SS17 Aufgabe 6 b)
https://q2a.cs.uni-kl.de/250/se_1-ak-ss17-aufgabe-6-b?show=251#a251
<p><span style="font-family:'t1xtt'; font-size:10.000000pt">1. (</span><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span><span style="font-family:'t1xtt'; font-size:10.000000pt">x y </span><span style="font-family:'txsy'; font-size:10.000000pt">→ </span><span style="font-family:'t1xtt'; font-size:10.000000pt">(</span><span class="detail_character_unicode">λ</span><span style="font-family:'t1xtt'; font-size:10.000000pt">x y </span><span style="font-family:'txsy'; font-size:10.000000pt"><span class="detail_character_unicode">→</span> </span><span style="font-family:'t1xtt'; font-size:10.000000pt">a y x) y x)</span> // kurze Schreibweise</p><p><span style="font-family:'t1xtt'; font-size:10.000000pt">2. (</span><span style="font-family:'rtxmi'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span></span><span style="font-family:'t1xtt'; font-size:10.000000pt">x </span>→<span style="font-family:'txsy'; font-size:10.000000pt"> </span><span style="font-family:'t1xtt'; font-size:10.000000pt">(</span><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span><span style="font-family:'t1xtt'; font-size:10.000000pt">y </span>→<span style="font-family:'txsy'; font-size:10.000000pt"> </span><span style="font-family:'t1xtt'; font-size:10.000000pt">((</span><span style="font-family:'rtxmi'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span></span><span style="font-family:'t1xtt'; font-size:10.000000pt">x </span><span style="font-family:'txsy'; font-size:10.000000pt">→ </span><span style="font-family:'t1xtt'; font-size:10.000000pt">(</span><span style="font-family:'rtxmi'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span></span><span style="font-family:'t1xtt'; font-size:10.000000pt">y </span><span style="font-family:'txsy'; font-size:10.000000pt">→ </span><span style="font-family:'t1xtt'; font-size:10.000000pt">(a y) x)) y) x)) // volle Klammerung</span></p><p><span style="font-family:'t1xtt'; font-size:10.000000pt">3. (</span><span style="font-family:'t1xtt'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span></span>x </span><span style="font-family:'t1xtt'; font-size:10.000000pt">→ (</span><span style="font-family:'t1xtt'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span></span>y </span><span style="font-family:'t1xtt'; font-size:10.000000pt">→ (</span><span style="font-family:'t1xtt'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span></span>x </span>→<span style="font-family:'t1xtt'; font-size:10.000000pt"> (</span><span style="font-family:'t1xtt'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span style="font-family:'rtxmi'; font-size:10.000000pt"><span class="detail_character_unicode">λ</span></span></span>y </span><span style="font-family:'t1xtt'; font-size:10.000000pt">→ a y x))) y x) // Ihre Klammerung</span></p><p>Die Klammern sind korrekt so wie Sie sie gesetzt haben. Man kann aber noch weitere Klammern einfügen.</p><p>Für Funktionsaufrufe gilt:</p><p>f x y = (f x) y</p><p>(das heißt y ist ein Parameter für die Funktion (f x) und nicht ein Parameter von x)</p><p>Daher kommen die anderen beiden Klammerpaare in der Aufgabenstellung.</p><p>Die Regeln für die verkürzte Schreibweise sind übrigens im Skript 25 (Programmierparadigmen) auf Seite 4 unten.</p><p></p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/250/se_1-ak-ss17-aufgabe-6-b?show=251#a251Thu, 06 Sep 2018 08:24:49 +0000Answered: Ist es erlaubt, ein Cheat Sheet in der ReSy-Klausur zu verwenden, wie auch in anderen Vorlesungen? (SE2, FGdP, ...)
https://q2a.cs.uni-kl.de/40/erlaubt-cheat-sheet-klausur-verwenden-anderen-vorlesungen?show=73#a73
<p>Entgegen der bisherigen Ankündigungen haben wir uns nun doch dazu entschieden, Cheat sheets in der Klausur "Rechnersysteme 1" zuzulassen. s ist deshalb erlaubt, <strong>ein einseitig beschriebenes DIN A4 Blatt</strong> mit eigenen Notizen in der Klausur als Hilfsmittel zu verwenden. Die ARM-Befehlsreferenz wird weiterhin wie angekündigt Bestandteil der Klausur als Anhang bleiben.</p><p>[EN] Contrary to previous announcements, we have now decided to accept cheat sheets in the "Rechnersysteme 1" exam. It is therefore permitted to use a single-sided DIN A4 sheet with your own notes in the exam. As announced, the ARM command reference will still be included in the exam (annex).</p># Mandatory Modules Bachelorhttps://q2a.cs.uni-kl.de/40/erlaubt-cheat-sheet-klausur-verwenden-anderen-vorlesungen?show=73#a73Wed, 15 Aug 2018 15:39:47 +0000