
236 Data Structures Using C
6.3.2 Travelling a Linked List
Many a times, it is required to travel whole or a part of the list. For example, the operations such as
counting of nodes, processing of information of some nodes, or printing of the list, etc. requires traversal
of the list.
Consider the linked list shown in Figure 6.12. It is pointed by First. Let us travel this list for the
purpose of counting the number of nodes in the list.
Fig. 6.12 The list pointed by First
isIndia Great Country
First
NUL
Let us use a pointer ptr to travel the list. A variable called count would be used to count the
number of nodes in the list. The ...