The question pretty much says it all, but I’m building a compiler and am trying to decide on what sort of data structure to use for my symbol table. Considering the only functions the symbol table will need is a search and an insert I’d like to use a data structure that can do those as quickly as possible. Any suggestions?
Share
Hash tables are very commonly used for this. A simple implementation with
Nbins and a hash function that takes the sum of the letters in each symbol (mod N) should be very close to O(1) on insert and search.