If you operate this operation on a single-linked table or a linked list indicated by a head pointer, it will consume performance because you need to traverse the first linked list, locate an, and link b1 to an. the time complexity is: O (n ). If it is implemented on the single-loop linked list indicated by the tail pointer, you only need to change the pointer without traversing. the time complexity is: O (1)
The following four main steps are required for Algorithm Implementation:
LinkList Connect (LinkList A, LinkList B) {// assume that A and B are the end pointer LinkList p = A-> next; // 1. The position of the header node that stores the linked list is A-> next = B-> next; // 2. link the end of Table A to table B to free (B-> next) at the Start Node of expression B; // 3. Release B to express the header Node B-> next = P; // 4. Link next at the end of expression B to return B to the header of expression A; // return the tail pointer of the new cyclic linked list}