Name

set_union

Synopsis

int set_union(Set *setu, const Set *set1, const Set *set2);

Return Value

0 if computing the union is successful, or -1 otherwise.

Description

Builds a set that is the union of set1 and set2. Upon return, setu contains the union. Because setu points to data in set1 and set2, the data in set1 and set2 must remain valid until setu is destroyed with set_destroy.

Complexity

O (mn), where m and n are the number of members in set1 and set2, respectively.

Get Mastering Algorithms with C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.