At first, we chose to use the ADT operation to allocate storage space. later I found that. in this way, there are so many problems that no analysis results will be produced after the analysis. simply go straight to the problem. My thoughts are good, I admit.
UpperCode.
/* Disjiontadt. C -- Non-intersecting set implementation file */<br/> # include <stdio. h> <br/> # include <stdlib. h> <br/> # include "disjiontadt. H "</P> <p>/* interface function definition */</P> <p> void initializeasheight (disjiontset gather, const int size) <br/>{< br/> int I; </P> <p> gather [0] = size; <br/> for (I = 1; I <= size; I ++) <br/> gather [I] = height; <br/>}</P> <p> void initializeassize (disjiontset gather, const int size) <br/>{< br/> int I; </P> <p> gather [0] = size; <br/> for (I = 1; I <= size; I ++) <br/> gather [I] = size; <br/>}</P> <p> int setunionasheight (disjiontset gather, settype root1, settype root2) <br/>{< br/> If (gather [root1]> 0 | gather [root2]> 0) <br/> return 0; <br/> If (gather [root2] <gather [root1]) <br/> gather [root1] = root2; <br/> else <br/> {<br/> If (gather [root1] = gather [root2]) <br/> gather [root1] --; <br/> gather [root2] = root1; <br/>}</P> <p> return 1; <br/>}</P> <p> int setunionassize (disjiontset gather, settype root1, settype root2) <br/> {<br/> If (gather [root1]> 0 | gather [root2]> 0) <br/> return 0; <br/> If (gather [root2] <gather [root1]) <br/> {<br/> gather [root2] + = gather [root1]; <br/> gather [root1] = root2; <br/>}< br/> else <br/> {<br/> gather [root1] + = gather [root2]; <br/> gather [root2] = root1; <br/>}</P> <p> return 1; <br/>}</P> <p> settype find (disjiontset gather, const item) <br/>{< br/> If (item> gather [0]) <br/> return OOS; <br/> else if (gather [item] <= 0) <br/> return item; <br/> else <br/> return gather [item] = find (gather, gather [item]); <br/>}