What are Lists and Self-Organizing lists in compiler design?

Compiler DesignProgramming LanguagesComputer Programming

Lists

  • It is conceptually simplest and easy to implement a data structure for the symbol table in a linear list of records, as shown below −

  • It can use an individual array to store the name and its associated information. New Names are inserted to the list in the order in which they are encountered. It can retrieve data about a name we search from the starting of the array up to the position marked by the pointer AVAILABLE which indicates the beginning of the empty portion of the array.
  • When the name is placed, the associated data can be discovered in the words following next. If we reach available without identifying the name, it can fault in the use of an undefined name.
  • It can insert n names and m inquires the total work is c(n+m) where c is constant representing the time necessary for new machine operations.It can insert n names and m inquires the total work is c(n+m) where c is constant representing the time necessary for new machine operations.

Some fact about list data structure

  • Work essential to add a new name is proportional to n, where the symbol table contains n names.
  • Cost of searching a name in the list is proportional to n/2.
  • To insert n names and m enquiries, total work is

                     cn (n + m)               where c is constant

Advantage

  • It is used to minimum space requirement.
  • It is easy to understand & implement.

Disadvantage

  • It is used for sequential access
  • The amount of work done needed to be done is high.

Self-Organizing List

At the cost of a little extra space, it can use a trick that will save a substantial fraction of the time spent in searching the symbol table. It can add a LINK field to each record, and we search the list in the order indicated by LINK’s. The figure shows an example of four name symbol table.

FIRST, give the position of the first record on the linked list, and each LINK field denotes the next record on the list. When a name is referenced or its record is first created, it can move the record for that name to the front of the list by moving pointers.

This approach is used to decrease searching time in list organization. A special attribute link is added to the information of name that allows dynamic feature in the list, and this feature helps in minimizing wastage of spaces and also promotes reusability to some extent.

First Pointer points to the starting of the symbol table.

If we have names in the following order.

3 → 1 → 4 → 2

If we need a particular record, we need to move the record to the front of the list.

Suppose we need 4 so, new connections will be

4 → 3 → 1 → 2

Advantage

  • It can increase search efficiency.
  • It can promote reusability to some extent.

Disadvantage

  • It can difficult to maintain so many links and connections.
  • It can extra space requirement is there.


raja
Published on 08-Nov-2021 10:08:19
Advertisements