Main function.
46{
48
49
50 for (int i = 0; i < 10; i++)
51 {
52 union_set[i] = i;
53 }
54
55
56 join(union_set, 3, 5);
57 printf("The array is now: ");
58 for (int i = 0; i < 10; i++)
59 {
60 printf("%d ", union_set[i]);
61 }
62 printf("\n");
63
64
65
66 join(union_set, 3, 8);
67 printf("The array is now: ");
68 for (int i = 0; i < 10; i++)
69 {
70 printf("%d ", union_set[i]);
71 }
72 printf("\n");
73
74
75
76 join(union_set, 0, 5);
77 if (
find(union_set, 0) ==
find(union_set, 3))
78 {
79 printf("0 and 3 are groupped together\n");
80 }
81 printf("The array is now: ");
82 for (int i = 0; i < 10; i++)
83 {
84 printf("%d ", union_set[i]);
85 }
86 printf("\n");
87
88 return 0;
89}
void join(int *p, int x, int y)
Function to join.
Definition: union_find.c:42