Question: **Java program** A symbol table is a data structure used by compilers to store information about identifiers in a program such as variables, methods, and

**Java program**

A symbol table is a data structure used by compilers to store information about identifiers in a program such as variables, methods, and classes. In this exercise you are asked to implement a symbol table that will store the identifiers of a Java program and their associated access modifiers (public, private, protected, default/package-private). The following aspects are to be observed:

- Element information is a pair (identifier, access), where identifier is the identifier name andaccess is the corresponding access modifier. Both identifier and access are strings of characters.

- Elements will remain in memory the entire time, so a remove method is not required.

- Elements will be read into your program from a text file with one pair (identifier, access) in each

line. For example,

x private y public p1 protected

firstName default

lastName default

taxValue public

The input file should contain at least 50 entries.

- SymbolTable, your main data structure, will be implemented with a hash table that will store the symbol table elements, i.e. pairs (identifier, access). Hash table size [20, 30]. The key of an element is the identifier component.

- Collisions will be resolved using a modification to the chaining approach discussed in class: instead of linked lists, a binary search tree will be used to store the elements with the same hash value.

- Hash function to be used is the one implemented in class on exercise Prog23_01.

- To implement the binary search tree, use solution in Prog22_01

modified appropriately.

- Create a Main class to test your SymbolTable class.

Using the UML below:

 **Java program** A symbol table is a data structure used by

Design The design is described in the UML class diagram Main +static void main(String[args) +Main SymbolTable ElementType -int tableSize BinarySetable +Symbol Table0) +Symbol Table(int size) -int hash(String key) +void add(ElementType e) +boolean search(String key) +String toString) +String identifier +String access +ElementType) +ElementType(String i, String a) +String toString() Node BinarySearchTree ElementType info Node left Node right +Node() +ElemenType getlnfo() +Node getLeftChild() +Node getRightChild() +void setNode(ElementType x, Node I, Node r) +void setlnfo(ElementTypex) +void setLeftChild(Node l) +void setRightChild(Node r) +String toString0) Node root +Binary SearchTree0) +void add(ElementType x) +boolean contains(String x) +boolean isEmpty +String toString) -void add(ElementType x, Node p) -boolean contains(String x, Node p) -String toString(Node p)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!