Machine-translated by Google. Questions are authored in English.
Top

Symbol Table Management Questions and Answers

Answer: C

Nesting the tables mirrors the nesting of scopes in the source. Discarding or unlinking the local table on leaving the procedure restores the enclosing visibility. The table itself is often retained for the benefit of a debugger.

Please log in or register to report this question.

Answer: D

Correct answer: a table of their own attached to the record's type entry

The fields form a scope of their own: two records may both have a field called next without conflict, and a field name means nothing outside its record. Giving each record type its own table expresses that directly, and the table also carries the offsets computed during declaration processing.

Please log in or register to report this question.

Answer: A

The field is reached only through a record value, so no ambiguity arises. This separation is what allows a field called next in many different record types. Without it, field names would compete with ordinary variables for the same space.

Please log in or register to report this question.

Answer: B

Each field is placed at the running total, which then advances by that field's width. Alignment requirements may insert padding, which the total must account for. Reordering the fields can reduce that padding considerably.

Please log in or register to report this question.

35.

A record has fields of widths 4, 8 and 2 bytes laid out in that order with no padding. What offset does the third field occupy?

Answer: C

Correct answer: 12

With no padding the offsets are cumulative from zero: the first field at 0, the second at 4, and the third at \( 4 + 8 = 12 \). The offset is the running total of the widths before the field, which is why the third field’s own width of 2 does not enter the calculation.

Please log in or register to report this question.

36.

A hash table with 128 buckets holds 512 entries using separate chaining. What is the average chain length?

Answer: D

Correct answer: 4

\[ \frac{512}{128} = 4. \] This is the load factor, and it is what governs lookup cost under separate chaining: each search examines about four entries on average. Doubling the number of buckets would halve it, which is why hash tables are grown as they fill.

Please log in or register to report this question.

Answer: A

The bucket a name belongs to depends on the table size, so every entry must be placed again. The cost is amortised over the many insertions between resizes. Doubling the size each time keeps the amortised cost per insertion constant.

Please log in or register to report this question.

Answer: B

An expression's type is built from the types of its operands, and the types of names come from their declarations. Without the table no typing would be possible at all. Every operator then checks its operand types against what it will accept.

Please log in or register to report this question.

Answer: C

Correct answer: a failed lookup through the whole chain of enclosing scopes

The name is looked up in the innermost scope, then in each enclosing one in turn, and only when every scope has been searched can it be declared undeclared. The parser accepts the identifier as syntactically valid, so this is a semantic error rather than a syntactic one.

Please log in or register to report this question.

Answer: D

One diagnostic per undeclared name is far more useful to the programmer than one for every occurrence of it, which in a long procedure could run to dozens of identical messages. No code is generated for a program containing such an error, so the placeholder affects only the reporting rather than the translation.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Symbol Table Management Questions and Answers || Symbol Table Management MCQ Questions and Answers || Symbol Table Management GK Questions and Answers || Symbol Table Management GK MCQ Questions || Symbol Table Management Multiple Choice Questions and Answers || Symbol Table Management GK || GK on Symbol Table Management || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design