zf*****@umd.umich.edu wrote:
Can anyone suggest some resources (websites/books) to learn coding
discrete math problems?
I have a problem involving sets,relations and functions and even
though the logic is clear I dont know the syntax for inputting
relations as ordered pairs, testing for functions, compositions and
inverses etc.
To model functions in C++, you can use std::map<>. To model relations, you
could use std::multiset<>. This assumes that you are mainly applying these
relations and functions in a forward fashion (first coordinate search is
fast, dependent variable search is linear). If you need a more symmetric
data structure, you can use two (multi)maps, one for the function/relation,
and one for its inverse. Adding a pair is done by the insert() member
function.
This might get you started. If you get stuck, post a piece of code that
demonstrates the problem.
Best
Kai-Uwe Bux