Skip to content
Official PYQ · 1987

GATE CS 1987 Q1-xvii — Lexical Analysis

Explain with AI

Using longer identifiers in a program will necessarily lead to:

Choose one option
View worked solution

Answer: A

The correct option is A.

During the compilation process, identifiers are processed primarily by the lexical analyzer (scanner) and the symbol table:

  1. Lexical Analysis: The scanner reads the source code character by character. Longer identifiers mean more characters must be read from the input buffer, increasing the time spent in the scanning phase.
  2. Symbol Table Operations: Operations such as insertion, lookup, and string comparison in the symbol table depend on the length of the identifier. For example, computing a hash value or performing string comparisons takes time proportional to the length of the string (O(L)O(L), where LL is the length of the identifier).

Thus, longer identifiers will necessarily lead to somewhat slower compilation, even if the difference is very small in modern systems.

Why other options are incorrect:

  • Option B: While meaningful names improve readability, longer identifiers do not necessarily make a program easier to understand (e.g., using long, random, or poorly-named strings like aaaaabbbbbccccc).
  • Option C: The length of identifiers has no bearing on the logical correctness of a program.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Lexical Analysis questions