Lecture 1.Pptx 3
Lecture 1.Pptx 3
Facilitator : Dr.S.Saraswathi
Symbol Table
Introduction
• Symbol table is an important data structure created and
maintained by compilers in order to store information about the
occurrence of various entities such as variable names, function
names, objects, classes, interfaces, etc.
• Hash table
Operations
2. better coding structure Symbol tables can be used to organize and simplify code, making
it simpler to comprehend, discover, and correct problems.
3. Faster code execution: By offering quick access to information like memory addresses,
symbol tables can be utilized to optimize code execution by lowering the number of
memory accesses required during execution.
1. Symbol tables can be used to increase the portability of code by offering a standardized
method of storing and retrieving data, which can make it simpler to migrate code between
other systems or programming languages.
3. Symbol tables can be used to facilitate easy access to and examination of a program’s
state during execution, enhancing debugging by making it simpler to identify and correct
mistakes.
Disadvantages of Symbol Table
1. Increased memory consumption: Systems with low memory resources may suffer from symbol tables’ high
memory requirements.
2. Increased processing time: The creation and processing of symbol tables can take a long time, which can be
problematic in systems with constrained processing power.
3. Complexity: Developers who are not familiar with compiler design may find symbol tables difficult to construct
and maintain.
4. Limited scalability: Symbol tables may not be appropriate for large-scale projects or applications that require o
the management of enormous amounts of data due to their limited scalability.
5. Upkeep: Maintaining and updating symbol tables on a regular basis can be time- and resource-consuming.
6. Limited functionality: It’s possible that symbol tables don’t offer all the features a developer needs, and therefore
more tools or libraries will be needed to round out their capabilities.
Static and Dynamic Data Structure
Aspect Static Data Structure Dynamic Data Structure
Size Size is fixed and cannot be modified Size can be modified during runtime
Memory utilization Memory utilization may be inefficient Memory utilization is efficient as memory can be reused
Examples Arrays, Stacks, Queues, Trees (with fixed size) Lists, Trees (with variable size), Hash tables
Advantage of Static data structure :
• Fast access time
• Predictable memory usage
• Ease of implementation and optimization
• Efficient memory management
• Simplified code
• Reduced overhead
Advantage Of Dynamic Data Structure
:
• Flexibility
• Reduced memory waste
• Improved performance for some operations
• Simplified code
• Scalability
Static Tree Table
Huffman Algorithm
•b 001
•c 010
For a file with 105 characters, we need 3 x 105 bits.
•d 011
•e 100
•f 101
A variable-length code
• It can do considerably better than a fixed-length code, by
giving many characters short code words and infrequent
character long codewords.
• a 0
• b 101
• c 100
• d 111
• e 1101
• f 1100
• Number of bits = (45 x 1 + 13 x 3 + 12 x 3 + 16 x 3 + 9 x 4 + 5 x 4) x 1000
• = 2.24 x 105bits
Algorithm of Huffman Code
Huffman (C)
1. n=|C|
2. Q ← C
3. for i=1 to n-1
4. do
5. z= allocate-Node ()
6. x= left[z]=Extract-Min(Q)
7. y= right[z] =Extract-Min(Q)
8. f [z]=f[x]+f[y]
9. Insert (Q, z)
10. return Extract-Min (Q)
Find an optimal Huffman Code for the following set of
frequencies: a: 50 b: 25 c: 15 d: 40 e: 75
Again for i=2
Similarly, we apply the same process we get
Thank you