A linked list is a data structure composed of zero or extra nodes linked by pointers. Each node consists of two parts, as shown in Figure: info field having specific information and next field having address of next node. First node is pointed by an external pointer called head. Last node called tail node does not have address of any node. Therefore, its next field points to null. Linked list with zero nodes is known as null linked list.
A large number of operations can be presented using the linked list. For some of the operations like insertion or deletion of the latest data, linked list takes constant time, but it is time consuming for a few other operations like searching a data. We are giving here an instance where linked list is used:
Given a linear linked list, rank the list elements in terms of the distance from each to the last element.
A parallel algorithm for this query is given here. The algorithm assumes there is p number of processors.
Processor j, 0≤ j
else rank[j] =1 endif
while rank[next[first]]≠0 Processor j, 0≤ j
The working of this algorithm is showing by the following diagram:
Finding rank of elements