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

Symbol Table Management Questions and Answers

Answer: A

Correct answer: a store of the names in a program together with their attributes

The symbol table is the compiler’s record of what every name means: its type, its scope, its storage, its parameters if it is a procedure. Nearly every phase consults it, which is why it is a data structure shared across the whole compiler rather than belonging to any one pass.

Please log in or register to report this question.

Answer: B

Correct answer: the number of times the name appears in the source text

A count of occurrences serves no purpose in translation and is not kept. The attributes recorded are those the later phases need - type for checking, scope for resolution, storage location for code generation - and each earns its place by being consulted.

Please log in or register to report this question.

Answer: C

Correct answer: the scanner, at the moment the identifier is first recognised

The scanner recognises the identifier and enters it in the table, returning a pointer to the entry as part of the token. Later phases fill in the attributes as they become known: the parser and semantic analyser supply type and scope, and the code generator the storage.

Please log in or register to report this question.

4.

Match each phase with what it does to the symbol table.
List I
A. lexical analysis
B. semantic analysis
C. code generation
D. optimisation
List II
1. reads the storage offset assigned
2. installs the name and its lexeme
3. consults attributes to decide on transformations
4. records the type and checks declarations

Answer: D

Each phase touches the table for its own purpose, writing what it knows and reading what an earlier phase recorded. Because the one structure is shared across the whole compiler, its design has to satisfy every one of those needs at once rather than being tuned for any single phase.

Please log in or register to report this question.

Answer: A

A tree keeps its keys ordered, which a hash table does not. Compilers do not need ordered traversal, so the faster average lookup of a hash table is bought at no real cost, and only a cross reference tool would miss the ordering.

Please log in or register to report this question.

Answer: B

Every entry may have to be examined. The simplicity is attractive for a very small table, but the cost becomes unacceptable once a program declares more than a handful of names. Real programs declare thousands, so the structure is of historical interest only.

Please log in or register to report this question.

Answer: C

Correct answer: logarithmic in the number of entries

A balanced tree halves the search space at each step, giving \( O(\log n) \) lookup, and it keeps the entries in order - useful for producing a sorted listing. A hash table is faster still, at constant average cost, but loses the ordering.

Please log in or register to report this question.

8.

Match each symbol table implementation with its typical lookup cost.
List I
A. unordered linear list
B. balanced search tree
C. hash table
D. hash table with every key colliding
List II
1. near constant on average
2. linear in the entry count
3. linear in the entry count
4. logarithmic in the entry count

Answer: D

The comparison is what drives the choice in practice. A hash table wins on average but degenerates to a list in the pathological case, which is why the hash function matters. A well chosen function makes that case vanishingly unlikely in practice.

Please log in or register to report this question.

Answer: A

Distinct names sharing a bucket is unavoidable once the number of possible names exceeds the number of buckets. Chaining and open addressing are the two standard responses. The pigeonhole principle makes collisions unavoidable in any real table.

Please log in or register to report this question.

Answer: B

Each bucket holds a pointer to a list of the entries that hashed there. Lookup hashes once and then walks a short list, which stays cheap provided the load factor is kept modest. Unlike open addressing, chaining continues to work when the table is overfull.

Please log in or register to report this question.

Loading…
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