- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is representation of fixed-length and variablelength array representation in the symbol table?
Symbol Table is a data structure that supports an effective and efficient way of storing data about various names occurring in the source code. These names are used in the source code to identify the different program elements, like a variable, constants, procedures, and the labels of statements.
The symbol table is searched each time a name is encountered in the source text. When a new name or new data about an existing name is found, the content of the symbol table modifies. Thus, the symbol table should have an effective structure for creating the data held in the table also for inserting new entries to the symbol table.
There are numerous ways of representing names in symbol table such as fixed-length array representation and variable-length array representation.
Fixed-Length Array Representation
It is one of the easiest methods of representing names in contiguous array records.
Name field of the symbol table is of fixed size.
Similarly, size is also fixed for the amount of information that can be stored for a particular name.
Consider IBM 370 Representation
- Length of Identifier = 08 characters
- Amount of Information = 16 characters
Suppose each block can only 4 characters. Hence we require 2 blocks to store an identifier and 4 blocks to keep its information.
Let us Consider the name DONALD.
It is visible that space allocated to the name is wasted as only one and a half block is occupied. However, 2 blocks are given for the name. Let us consider another example.
Here there is a wastage of one complete block. We summed up this using the following diagram. Shaded boxes in the symbol tables denote wastage of memory.
- It is easy to understand.
- It is easy to implement and access.
- Wastage of a large amount of memory.
- Sequential access
- Insertion and deletion of records are comparatively very slow.
- It requires large processing and memory requirements.
Variable Length Array Representation
Instead of storing names directly in the symbol table, it will save all names in an independent array of characters and will only keep the start index and length of the name. This will overcome the disadvantage of a fixed-length name. Now it can have a variable length exceeding 8 characters as it was fixed in the previous method. Similarly, we can represent the previous example as
- A variable name can be of any length.
- Ease of Access.
- No wastage of memory in the symbol table.
- The symbol table now more organized.
- It can facilitate quicker editing.
- The problem of indirection maintenance.
- The requirement of extra array records for storing variable names.
- What is Array Name Representation in Symbol Table?
- What is Fixed Point Representation in Computer Architecture?
- Array Representation Of Binary Heap
- Array of Arrays Representation in Data Structure
- What is the Representation of DFA in compiler design?
- What is Instance-based representation?
- What is two array representations in the symbol table?
- ADT-array Representation in Data Structure
- What is types of Intermediate Code Representation?
- What are the representation of FP-Tree?
- An Uncommon representation of array elements in C/C++
- An Uncommon representation of array elements in C++ program
- Representation of fractions
- Representation of Graphs
- What is Floating-Point Representation in Computer Architecture?