When looking at the header file of Set ADT in C, I'm trying to understand why was the function setUnion or setIntersection declared that way:
Set setUnion(Set set1, Set set2);
Set setIntersection(Set set1, Set set2);
I couldn't find the implementation but I'm assuming that inside those functions, we allocate more space and create new set, and then add all the necessary elements. I thought that set1 and set2 are passed by reference, so why not update one of them and save mem allocations and just return some enum that notifies whether the update succeeded or not? (for example we can update the left parameter).
If they're not passed by reference, how can I change the signature in order to do so?
Thank you!