Question: Homework: # 5 : Dynamic Sets Objects / Structures involved They are the same set involved in HM 4 . Student class studNode struct (
Homework: #: Dynamic Sets
Objects Structures involved
They are the same set involved in HM
Student class
studNode struct unsigned int, Student
SnEsa class Orderable Array HM of studNodes
Usual ops: getNum, get, store, prepend, append, insert, remove
This homework will add additional methods to the SnESA
class to create a Dynamic Set capability.
SnEsa Sunion const SnEsa const; Inclusive OR
snEsa Sintersect const SnEsa const; AND
Intersect: Unordered Set C Code
SnEsa Sintersect const SnEsa B Put the intersect with B in C
int a b c ;
studNode sb null sa null;
int bmax BgetNum ; int amax thisgetNum ; Get Set sizes
int cmax bmax amax bmax: amax; Max size of new set size of smaller set
SnEsa C new SnEsa cmax; Get ptr to SnEsa large enough to hold everything
for a ; a amax; a For each element in A
for b ; b bmax; b For each element in B ~ if match, if not
if thisgetaidBgetbid Aa Bb
Cappend thisgeta; Append ptr to matched studNode to set C
break; Start testing with next A value
Either match found or not. Start next A element checks
All elements in Set A checked against all elements in Set B
return C; Return ptr to set which is unordered intersection of A and B
Homework : Dynamic Set Unions
Implement the following function ways:
SnEsa Sunion const SnEsa const; Inclusive OR
Write the C code for the Union of ordered sets all
SnEsas studNode entries are ordered by studNode
UID where the resulting SnEsa is an ordered set.
Write the C code for the Union of unordered sets
neither SnEsas studNode entries are ordered where
the resulting SnEsa is an unordered set.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
