a) Arrays as data structures are considered to have better performance in comparison to symbol tables. In the lecture, you might have noticed an example of a symbol table defined for keys of type Integer (e.g. , ). Provide an example that justifies the use of the symbol table that utilizes Integer as a key over an array. Explain your choice.\
b)One of many potential use cases for symbol tables discussed in the lecture is its implementation for a compiler, where one of the features a symbol table can be used for is value propagation. Describe the role of a symbol table in value propagation process that takes place within a compiler and provide an example of a scenario where value propagation might not result in performance improvement.
Populate a symbol table using the textbook's symbol table API.
(c) Use the table below to determine the proper operations to create and fill a symbol table with courses that Professor Ruben will be teaching for Spring of 2019.
COURSE | SEATS OCCUPIED |
SER222 | 47 |
SER315 | 63 |
SER334 | 38 |
SER401 | 40 |
SER415 | 42 |
(d) Before the beginning of the semester starts SER222 is canceled and will need to be removed from the symbol table. The number of occupied seats for SER401 have increased from 40 to 60students and the number of occupied seats for SER315 have decreased from 63 to 58. Provide the code that would update your data symbol table with the provided scenario. Also provide the code that will print out all the keys located in the updated symbol table.
e) reasoning behind this? Also provide an scenario for which the value of null might be useful in your symbol table?
a.answer:
Symbol Tables
The main operations of a symbol table are put, get, delete, contains & isEmpty.
The put operation inserts a key-value pair into the table (remove key from table if value is null), get returns a value given it’s key (null if not exist), delete or removes key and it’s value from table, and contains checks if there’s a value paired with a given key.
Symbol Table Conventions
There are several choices we’ve made for our implementations to make our code consistent, and useful.
— Generics
Key and Value type is any generic type.
— Duplicate Keys
Only one value is associated with each key (no duplicate keys in a table).
This convention is directly tied to put operation; overrides the old value with the new value if the that key already exists in the table.
— Null Values
No key can be associated with the value null.
This convention is directly tied to get operation; returns null for keys not in the table. The (intended) consequences of not having null values are:
— Deletion
Deletion in symbol tables generally involves either one of two strategies: lazydeletion, where we associate keys in the table with null (as we’ve just said), then perhaps remove all such keys later, and eager deletion, where we remove the key from the table immediately.
— Iterators
We can iterate over keys in the table. This can be done by defining a method for example called keys(), which returns an Iterable object.
b. answer:Symbol Table in Compiler
Prerequisite – Phases of a Compiler
Symbol Table is an important data structure created and maintained by the compiler in order to keep track of semantics of variable i.e. it stores information about scope and binding information about names, information about instances of various entities such as variable and function names, classes, objects, etc.
Symbol Table entries – Each entry in symbol
table is associated with attributes that support compiler in
different phases.
Items stored in Symbol table:
Information used by compiler from Symbol table:
Operations of Symbol table – The basic operations defined on a symbol table include:
a) Arrays as data structures are considered to have better performance in comparison to symbol tables....
Arrays as data structures are considered to have better performance in comparison to symbol tables. In the lecture, you might have noticed an example of a symbol table defined for keys of type Integer (e.g. <Integer>, <String>). Provide an example that justifies the use of the symbol table that utilizes Integer as a key over an array. Explain your choice.
Please help me answer the following questions regarding data relationship tables. Employee ID First Name Last Name email Title Address Extension Department Department ID Hiring Date Department Phone # 0001 John Smith jsmith Accountant 1300 West st 5775 Accounting 2100 8/1998 407-366-5700 0002 Brian Miller badams Admin Assistant 1552 Palm dr 5367 Human resource 2300 4/1995 407-366-5300 0003 James Miller miller Inventory Manager 2713 Buck rd 5432 Production 2520 8/1998 407-366-5400 0004 John Jackson jackson_sam Sales Person 433 tree dr...
PROBLEM STATEMENT: Suppose you have a client that has given you
the following business rules to form the basis for a database
design. The database must enable the manager of a company dinner
club to mail invitations to the club’s members, to plan the meals,
to keep track of who attends the dinners, and so on. Each dinner
serves many members, and each member may attend many dinners. A
member receives many invitations, and each invitation is mailed to
many...
please use dia to draw the e-r diagram to create Entity -
Relationship Diagrams
then use MS access
This project requires you to create a database design. Your design will be documented in a set of Entity-Relationship Crow's Foot diagrams using the representation as shown in the lecture materials. Draw a set of Entity-Relationship diagrams to model the following scenario. The Maggs Realty Company wants to track the Sales Offices that they have across all of Ontario They are interested...
Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....
ChangeRequest(CRID, CRType, CRTitle, CROriginDate, CRPriority, CRNeedEvent, CRStatus) NeedByEvent(Event) CRPrevState(CRID, CRState, StartDate, EndDate) CRAssigned(CRID, EmpID, StartDate, EndDate) Employees(EmpID, FirstName, LastName, JobTitle) ChangeRequest(CRID, CRType, CRTitle, CROriginDate, CRPriority, CRNeedEvent, CRStatus) The CRID is the primary key, it is unique, and it is an positive integer The CRType may be one of two values: "Deficiency" or "Enhancement" CRTitle is a variable length string that may be up to 2048 characters CROriginDate is a date CRPriority is an integer that may assume a value of...