There are many ways to implement a symbol table, and here are a few of them.
Unordered (unsorted) array implementations
In this case, you do not need to change the array, the operation is executed on this array. In the worst case, insert, search, delete time complexity is O (n).
Sequential (sorted) array implementations
In this case we have the sorted keyword and the corresponding value.
Store by keyword in an array
Keys[i] is the key of the I-bit large (keyword)
Values[i] is the value of the first-bit large key
Since elements are stored sequentially in an array, finding an element can be a simple two-point search. In the worst case, the search time complexity is O (log n), and the insertion and deletion time complexity is O (n).
The implementation of the chain list in the chaotic sequence
Just need to have a list of two elements on the line. The time complexity of searching, inserting, and Deleting is O (n).
Sequential chain list Implementation
In this way, when we insert elements, we want to keep the primitives ' keywords in order (such as size order). Even if the list is sorted, worst-case insertions, deletions, and search operation times are all O (n).
Some other implementation methods:
Binary Tree Implementation
Balanced binary Tree Implementation
Ternary Search Implementation
Hash Table Implementation
Comparison of the implementation methods of various symbol tables
Implementation |
Search |
Insert |
Delete |
Unordered Array |
N |
N |
N |
Ordered Array |
Log n |
N |
N |
Unordered List |
N |
N |
N |
Ordered List |
N |
N |
N |
Binary Search Trees (O (log n) on average) |
Log n |
Log n |
Log n |
Balanced Binary Search Tree |
Log n |
Log n |
Log n |
Ternary Search |
Log n |
Log n |
Log n |
Hashing (O (1) on average |
1 |
1 |
1 |
Symbol table implementation (symbol tables implementations)