Question
/** * inverse * returns the inverse of this symbol table. * the inverse is a symbol table where the roles of the Keys and
/**
* inverse
* returns the inverse of this symbol table.
* the inverse is a symbol table where the roles of the Keys and Values are switched
* Example:
* Consider the symbol table below, written as a collection of key value pairs
* A, 1
* B, 2
* C, 3
* The inverse this would be:
* 1, A
* 2, B
* 3, C
* In the original table, keys were Strings, values were Integers
* So in the inverse table, keys would be Integers and values would be Strings
* Note that the return type for the function is already correctly specified.
* That is: the invoking instance will be a Symbol table with key type: Key and value type: Value
* the inverse will be a symbol table with key type: Value and value type: Key *
* Note: if the symbol table contains duplicate values,
* you may use any of the corresponding keys for the inverse
* Example:
* A, 1
* B, 2
* C, 3
* D, 2
* 2 will become a Key in the inverse symbol table and its value could be either B or D
*/
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started