How to represent the inversion of a Key Value Pair (dictionary) in computer science within a math formula?

143 Views Asked by At

Having to represent the inversion of a KVP in a math formula, I would like to know how should I notate this principle?

I was going to use an inverted arrow above the letter representing the Key/value pair. Not to mention that I don't know how to represent a KVP within a formula, which would be helpful.

Thanks!

1

There are 1 best solutions below

4
On BEST ANSWER

I assume you are talking about notation? So for dictionaries and key-value pairs we can think of it as a mapping between the set of keys $K$ and the set of values $V$. We write this mapping as the function $f$ from

$$ f:K\rightarrow V $$

Now say we have a value and want to find out what key is attributed to that value. This would be an inverse mapping. Note that this requires $f$ to be a bijection. We would notate this as

$$ f^{-1}:V\rightarrow K $$

where if $f(v)=k$ then $f^{-1}(k) = v$