Page 52 - DCAP605_ADVANCED_DATA_STRUCTURE_AND_ALGORITHMS
P. 52
Unit 2: Linked Lists
r p Notes
NULL
temp q
NULL
NULL
After the fourth pass
r p
NULL
temp q
NULL
NULL
After the fifth pass
r p
NULL
temp
q
After the sixth pass
NULL
r p
10 20 30 40 NULL
temp
15 25 27 28
Final merged list
2.11 Merging of two Circular Lists
In order to merge or concatenate the two non-empty circular lists pointed to by p and q, it is
required to make the start of the resultant list p. Then the list pointed to by p is required to be
traversed until its end, and the link field of the last node must become the pointer q. After that,
the list pointed to by q is required to be traversed until its end, and the link field of the last node
is required to be made p.
LOVELY PROFESSIONAL UNIVERSITY 47