What are Symbol Tables?
We can define the symbol table as a data structure that associates a value with a key.It supports the following operations:
- Search whether a particular name is in the table
- Get the attributes of that name
- Modify the attributes of that name
- Insert a new name and its attributes
- Delete a name and its attributes
Three basic operations on symbol tables: searching, inserting, and deleting.
Example:
DNS lookup. Let us assume that the key in this case is the URL and the value is an IP address.
- Insert URL with specified IP address
- Given URL, find corresponding IP address
Symbol Table Implementations
Unordered Array Implementation:
With this method, just maintaining an array is enough. It needs O( n) time for searching, insertion and deletion in the worst case.Ordered [Sorted] Array Implementation:
In this we maintain a sorted array of keys and values.- Store in sorted order by key
- keys[ i] = ith largest key
- values[ i] = value associated with ith largest key
No comments:
Post a Comment