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

Symbol Table Management Questions and Answers

Answer: C

The false statement is Symbol table is not required after the parsing phase.

The symbol table is used throughout compilation. Semantic analysis reads it for type checking and scope resolution, intermediate code generation and optimisation use the attributes it stores, and the code generator needs the storage locations and sizes recorded in it. So it is very much required after parsing.

The other statements are true. The symbol table records which declaration a name refers to in each scope. It can be implemented with a hash table, a list or a binary search tree. And entries are typically created as identifiers are first met in lexical analysis, with attributes filled in by later phases.

Please log in or register to report this question.

2.

In a compiler, the data structure responsible for the management of information about variables and their attributes is

Exam Year(s)

Tripura Public Service Commission - 2019,

Answer: C

The data structure is the symbol table.

The symbol table records every identifier in the program together with its attributes: type, scope, storage location, and for functions the number and types of parameters. Every phase of the compiler consults or updates it.

A parser table drives the parsing decisions, a semantic stack holds values during syntax-directed translation, and an abstract syntax tree represents the program's structure, not the attributes of its variables.

Please log in or register to report this question.

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.

6.

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.

10.

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.

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