603 views
1 votes
1 votes
The dynamic-set operation $UNION$ takes two disjoint sets $S_1$ and $S_2$ as input, and it returns a set $S=S_1 \cup S_2$ consisting of all the elements of $S_1$ and $S_2$.The sets $S_1$ and $S_2$ are usually destroyed by the operation. Show how to support  $UNION$ in $O(1)$ time using a suitable list data structure.

1 Answer

0 votes
0 votes

we should follow this type of approach  like

S1:
A1->A2->A3

S2:
B1->B2->B3

Tail node of S1 (A3) linked to head node of S2 (B1)

S1US2:
A1->A2->A3*->*B1->B2->B3

Related questions

0 votes
0 votes
1 answer
2
akash.dinkar12 asked Jun 30, 2019
921 views
Give a $\Theta(n)$ time nonrecursive procedure that reverses a singly linked list of $n$ elements. The procedure should use no more than constant storage beyond that need...
1 votes
1 votes
1 answer
3
akash.dinkar12 asked Jun 30, 2019
618 views
Implement the dictionary operations $INSERT$, $DELETE$, and $SEARCH$ using singly linked, circular lists. What are the running times of your procedures?