Skip to content

Commit c1f73cc

Browse files
committed
s/####\s\s*answer/#### Answer/
Or in natural language: Substitute answer with Answer.
1 parent d1693e7 commit c1f73cc

File tree

14 files changed

+51
-51
lines changed

14 files changed

+51
-51
lines changed

ch02/2.2/2.2.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ S -> S S + | S S * | a
1010
2. Construct a parse tree for this string.
1111
3. What language does this grammar generate? Justify your answer.
1212

13-
#### answer
13+
#### Answer
1414

1515
1. `S` -> `S` S * -> `S` S + S * -> a `S` + S * -> a a + `S` * -> a a + a *
1616
2. ![Syntax tree](https://raw.github.com/fool2fish/dragon-book-practice-answer/master/ch02/2.2/assets/2.2.1-2.png)
@@ -26,7 +26,7 @@ What language is generated by the following grammars? In each case justify your
2626
4. S -> a S b S | b S a S | ε
2727
5. S -> a | S + S | S S | S * | ( S )
2828

29-
#### answer
29+
#### Answer
3030

3131
1. L = {0<sup>n</sup>1<sup>n</sup> | n>=1}
3232
2. L = {Prefix expression consisting of plus and minus signs}
@@ -38,7 +38,7 @@ What language is generated by the following grammars? In each case justify your
3838

3939
Which of the grammars in Exercise 2.2.2 are ambiguous
4040

41-
#### answer
41+
#### Answer
4242

4343
1. No
4444
2. No
@@ -65,7 +65,7 @@ the following languages. In each case show that your grammar is correct.
6565
3. Right-associative lists of identifiers separated by commas.
6666
4. Arithmetic expressions of integers and identifiers with the four binary operators +, - , *, /.
6767

68-
#### answer
68+
#### Answer
6969

7070
```
7171
1. E -> E E op | num
@@ -92,7 +92,7 @@ the following languages. In each case show that your grammar is correct.
9292

9393
2. Does the grammar generate all binary strings with values divisible by 3?
9494

95-
#### answer
95+
#### Answer
9696

9797
1. proof
9898

@@ -142,7 +142,7 @@ Construct a context-free grammar for roman numerals.
142142
**Note:** we just consider a subset of roman numerals which is less than 4k.
143143

144144

145-
#### answer
145+
#### Answer
146146

147147
[wikipedia: Roman_numerals](http://en.wikipedia.org/wiki/Roman_numerals)
148148

ch02/2.3/2.3.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ expressions from infix notation into prefix notation in which an operator
77
appears before its operands; e.g. , -xy is the prefix notation for x - y. Give
88
annotated parse trees for the inputs 9-5+2 and 9-5*2.
99

10-
#### answer
10+
#### Answer
1111

1212
productions:
1313

@@ -40,7 +40,7 @@ Construct a syntax-directed translation scheme that translates arithmetic
4040
expressions from postfix notation into infix notation. Give annotated parse
4141
trees for the inputs 95-2* and 952*-.
4242

43-
#### answer
43+
#### Answer
4444

4545
productions:
4646

@@ -73,7 +73,7 @@ E -> {print("(")} E {print(op)} E {print(")"}} op | digit {print(digit)}
7373
Construct a syntax-directed translation scheme that translates integers into
7474
roman numerals.
7575

76-
#### answer
76+
#### Answer
7777

7878
assistant function:
7979

@@ -114,7 +114,7 @@ high -> 5 {high.v = 5}
114114

115115
Construct a syntax-directed translation scheme that trans­ lates roman numerals into integers.
116116

117-
#### answer
117+
#### Answer
118118

119119
productions:
120120

@@ -168,7 +168,7 @@ digit -> smallDigit {digit.v = smallDigit.v}
168168
Construct a syntax-directed translation scheme that translates postfix
169169
arithmetic expressions into equivalent prefix arithmetic expressions.
170170

171-
#### answer
171+
#### Answer
172172

173173
production:
174174

ch07/7.2/7.2.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Suppose that the program of Fig.7.2 uses a partition function that always picks
88
2. What is the largest number of activation records that ever appear together
99
on the stack?
1010

11-
#### answer
11+
#### Answer
1212

1313
1. Draw the activation tree when the numbers 9,8,7,6,5,4,3,2,1 are sorted.
1414

@@ -43,7 +43,7 @@ In Fig. 7.9 is C code to compute Fibonacci numbers recur­sively. Suppose that t
4343
2. What dose the stack and its activation records look like the first time f(1) is about to return?
4444
3. ! What does the stack and its activation records look like the fifth time f(1) is about to return?
4545

46-
#### answer
46+
#### Answer
4747

4848
1. Show the complete activation tree.
4949

@@ -73,7 +73,7 @@ That is, function g calls f. Draw the top of the stack, starting with the acti­
7373
2. Which function writes the value of each element?
7474
3. To which activation record does the element belong?
7575

76-
#### answer
76+
#### Answer
7777

7878
![7 2 4](https://f.cloud.github.com/assets/340282/1267088/836d0550-2ca8-11e3-923d-757450951b13.gif)
7979

@@ -88,7 +88,7 @@ In a language that passes parameters by reference, there is a function f(x, y) t
8888

8989
If a is assigned the value 3, and then f(a, a) is called, what is returned?
9090

91-
#### answer
91+
#### Answer
9292

9393
x = x + 1 -> a = a + 1 -> now a is 4
9494
y = y + 2 -> a = a + 2 -> now a is 6
@@ -109,7 +109,7 @@ The C function f is defined by:
109109

110110
Variable a is a pointer to b; variable b is a pointer to c, and c is an integer currently with value 4. If we call f(c, b, a) , what is returned?
111111

112-
#### answer
112+
#### Answer
113113

114114
f(c, b, a) is 21
115115

ch07/7.3/7.3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In Fig. 7.15 is a ML function main that computes Fibonacci numbers in a nonstand
2525
2626
Figure 7.15: Nested functions computing Fibonacci numbers
2727

28-
#### answer
28+
#### Answer
2929

3030
activation tree:
3131

@@ -39,7 +39,7 @@ activation stack when first call to fib0(1) is about to return:
3939

4040
Suppose that we implement the functions of Fig. 7.15 using a display. Show the display at the moment the first call to fibO(1) is about to return. Also, indicate the saved display entry in each of the activation records on the stack at that time.
4141
42-
#### answer
42+
#### Answer
4343

4444
![7 3 2](https://f.cloud.github.com/assets/340282/1274690/d564dbc8-2dc3-11e3-828e-4740db58898d.gif)
4545

ch07/7.4/7.4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Suppose the heap consists of seven chunks, starting at address 0. The sizes of t
77
1. First fit.
88
2. Best fit.
99

10-
#### answer
10+
#### Answer
1111

1212
values in parentheses are sizes actually in use
1313

ch07/7.5/7.5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ What happens to the reference counts of the objects in Fig. 7.19 if:
1212

1313
Figure 7.19: A network of objects
1414

15-
#### answer
15+
#### Answer
1616

1717
1. The pointer from A to B is deleted.
1818

@@ -37,6 +37,6 @@ What happens to reference counts when the pointer from A to D in Fig. 7.20 is de
3737

3838
Figure 7.20: Another network of objects
3939

40-
#### answer
40+
#### Answer
4141

4242
![7 5 2](https://f.cloud.github.com/assets/340282/1276406/eac449f2-2e65-11e3-8e4c-def958552810.gif)

ch07/7.6/7.6.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Show the steps of a mark-and-sweep garbage collector on
99
3. Fig. 7.20 with the pointer A to D deleted.
1010
4. Fig. 7.20 with the object B deleted.
1111

12-
#### answer
12+
#### Answer
1313

1414
1. Fig. 7.19 with the pointer A to B deleted.
1515

@@ -60,7 +60,7 @@ Show the steps of a mark-and-sweep garbage collector on
6060

6161
The Baker mark-and-sweep algorithm moves objects among four lists: Free, Unreached, Unscanned, and Scanned. For each of the object networks of Exercise 7.6.1, indicate for each object the sequence of lists on which it finds itself from just before garbage collection begins until just after it finishes.
6262

63-
#### answer
63+
#### Answer
6464

6565
1. Fig. 7.19 with the pointer A to B deleted.
6666

@@ -117,7 +117,7 @@ starting at byte 0 of the heap.
117117

118118
What is the address of each object after garbage collection?
119119

120-
#### answer
120+
#### Answer
121121

122122
1. Fig. 7.19 with the pointer A to B deleted.
123123

@@ -133,7 +133,7 @@ Suppose we execute Cheney's copying garbage collection al­gorithm on each of th
133133

134134
What is the value of NewLocation(o) for each object o that remains after garbage collection?
135135

136-
#### answer
136+
#### Answer
137137

138138
1. Fig. 7.19 with the pointer A to B deleted.
139139

ch07/7.7/7.7.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Suppose that the network of objects from Fig.7.20 is managed by an incremental a
1313

1414
Simulate the entire incremental garbage collection, assuming no more pointers are rewritten. Which objects are garbage? Which objects are placed on the Free list?
1515

16-
#### answer
16+
#### Answer
1717

1818

1919
0. init
@@ -105,7 +105,7 @@ Repeat Exercise 7.7.1 on the assumption that
105105
2. Events (2) and (5) occur before (1), (3), and (4).
106106

107107

108-
#### answer
108+
#### Answer
109109

110110

111111
1. Events (2) and (5) are interchanged in order.
@@ -181,7 +181,7 @@ Repeat Exercise 7.7.1 on the assumption that
181181

182182
Suppose the heap consists of exactly the nine cars on three trains shown in Fig. 7.30 (i.e., ignore the ellipses). Object o in car 11 has references from cars 12, 23, and 32. When we garbage collect car 11, where might o wind up?
183183

184-
#### answer
184+
#### Answer
185185

186186
if any room in trains 2 and 3
187187
o can go in some existing car of either trains 2 and 3.
@@ -197,7 +197,7 @@ Repeat Exercise 7.7.3 for the cases that o has
197197
1. Only references from cars 22 and 31.
198198
2. No references other than from car 11.
199199

200-
#### answer
200+
#### Answer
201201

202202
1. Only references from cars 22 and 31.
203203

@@ -216,7 +216,7 @@ Repeat Exercise 7.7.3 for the cases that o has
216216

217217
Suppose the heap consists of exactly the nine cars on three trains shown in Fig. 7.30 (i.e., ignore the ellipses). We are currently in panic mode. Object o1 in car 11 has only one reference, from object o2 in car 12. That reference is rewritten. When we garbage collect car 11, what could happen to o1?
218218

219-
#### answer
219+
#### Answer
220220

221221
It is not important which train we move it to, as long as it is not the first train?
222222

ch08/8.2/8.2.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Generate code for the following three-address statements assuming all variables
2626

2727

2828

29-
#### answer
29+
#### Answer
3030

3131

3232

@@ -124,7 +124,7 @@ Generate code for the following three-address statements assuming a and b are ar
124124

125125

126126

127-
#### answer
127+
#### Answer
128128

129129

130130

@@ -192,7 +192,7 @@ Generate code for the following three-address sequence assuming that p and q are
192192

193193

194194

195-
#### answer
195+
#### Answer
196196

197197

198198

@@ -232,7 +232,7 @@ Generate code for the following sequence assuming that x, y, and z are in memory
232232

233233

234234

235-
#### answer
235+
#### Answer
236236

237237

238238

@@ -284,7 +284,7 @@ Generate code for the following sequence assuming that n is in a memory location
284284

285285

286286

287-
#### answer
287+
#### Answer
288288

289289

290290

@@ -414,7 +414,7 @@ Determine the costs of the following instruction sequences:
414414

415415

416416

417-
#### answer
417+
#### Answer
418418

419419

420420

ch08/8.3/8.3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ return
1414
return
1515
```
1616

17-
#### answer
17+
#### Answer
1818

1919
```
2020
100: LD SP, #stackStart

0 commit comments

Comments
 (0)