Let A and B be two data lists. Concatenation of the list A and another list B is defined to be equal to B, if

A is null; and is defined to be equal to concatenation of head of A with the concatenation of tail of A and
B, otherwise (where head of A is the first element of A, and tail of A is the list A after removing its head).
What is the time complexity behavior of this procedure for concatenation of lists?

I interpret this as:

if (A==φ)A|B == B
else A|B = Ha|Tab

But then we're defining A|B using Tab,
which is the tail of A|B. Sounds to me a circular definition.

Can you please clarify the definition, or give your comments?

well question related to advance analysis of algorithm i.e. BIG O

Are you already familiar with linked lists?

We assume A and B are singly linked lists, i.e. linked in the forward direction only.

To attain the end of a list, the node pointer must traverse every node from head to tail.

The number of operations is therefore n, where n=size of linked list A. Once the end-node is reached, it will then be made to point to, and replace, the head of list B. This means that the size of B is irrelevant.

Can you now find the big O from the above description?

well sir Thanks for the answer I understood the description but I am new in this subject.I still cant find big O.Really thankful for your act of kindness

The time complexity behavior of this procedure for concatenation of lists is linear or O(n), where n is the total number of elements in the list.

To understand why, let's break down the procedure step by step:

1. First, we check if list A is null. This is a constant-time operation, taking O(1).

2. If A is null, we directly return list B. Again, this is a constant-time operation, taking O(1).

3. If A is not null, we need to concatenate the head of A with the concatenation of the tail of A and B.

- Concatenating the head of A with another list takes O(1), as we only need to add one element to the beginning of the list.

- Concatenating the tail of A with B is where the recursive operation happens. Since we call the concatenation procedure recursively for the tail of A, we need to consider the time complexity for all the elements in A.

So, let's say A has n elements. For each element, we perform the concatenation operation, which includes adding the head of A to the beginning of the list. This takes constant time.

Therefore, the time complexity for the concatenation of tail of A with B would be O(n) since we need to perform this operation for each element in A.

Overall, considering all the recursive operations and assuming the worst-case scenario where we have to concatenate each element, the time complexity of this procedure for concatenating lists would be O(n), where n is the total number of elements in the list A.