Faster access to non-local variables is achieved using an array of pointers to activation records called a
View worked solution
Answer: C
The correct option is C.
In block-structured programming languages (such as Pascal), nested procedures can access variables declared in outer scopes (non-local variables). There are two primary techniques to implement this access:
- Static Links (Access Links): Accessing a non-local variable requires traversing a chain of pointers. If the variable is declared at a nesting depth levels shallower than the current procedure, we must traverse links, which takes time.
- Display: To achieve faster, constant-time () access to non-local variables, compilers use an auxiliary array of pointers called a display.
The -th entry of the display array points to the activation record of the most recently active procedure at nesting depth . Any non-local variable at nesting depth can be accessed directly in time by dereferencing the pointer at index of the display, followed by the local offset.
Why other options are incorrect:
- Stack: Used to store activation records in a Last-In-First-Out (LIFO) order, but does not directly provide access to non-local variables in nested scopes.
- Heap: Used for dynamic memory allocation (e.g., objects, lifetime extending beyond procedure calls).
- Activation Tree: A conceptual tree representing the entry and exit of control among various activation records during execution. It is not a data structure used for variable access.
Free practice · Your answers on this page are not saved.
