their address to the free poolso that these cells can be reused by other programs this process is called garbage collection there are different types of linked lists which we will discuss in the next section singly linked lists singly linked list is the simplest type of linked list in which every node contains some data and pointer to the next node of the same data type by saying that the node contains pointer to the next nodewe mean that the node stores the address of the next node in sequence singly linked list allows traversal of data only in one way figure shows singly linked list start figure singly linked list traversing linked list traversing linked list means accessing the nodes of the list in order to perform some processing on them remember linked list always contains pointer variable start which stores the address of the first node of the list end of the list is marked by storing null or - in the next field of the last node for traversing the linked listwe also make use of another pointer variable ptr which points to the node that is currently being accessed the algorithm to traverse linked list is shown in fig in this algorithmwe first initialize ptr with the address of start so nowptr points to the first node of the linked list then in step while loop is executed which is repeated till ptr processes the last nodethat is until it encounters null in step we apply the process ( printto the current nodethat isthe node pointed by ptr in step we move to the next node by making the ptr variable point to the node whose address is stored in the next field let us now write an algorithm to count the number of nodes in linked list to do thiswe step [initializeset ptr start will traverse each and every node of the list and step repeat steps and while ptr !null step apply process to ptr -data while traversing every individual nodewe will step set ptr ptr -next increment the counter by once we reach null[end of loopthat iswhen all the nodes of the linked list have step exit been traversedthe final value of the counter will be displayed figure shows the algorithm to figure algorithm for traversing linked list print the number of nodes in linked list step [initializeset count step [initializeset ptr start step repeat steps and while ptr !null step set count count step set ptr ptr -next [end of loopstep write count step exit figure algorithm to print the number of nodes in linked list searching for value in linked list searching linked list means to find particular element in the linked list as already discusseda linked list consists of nodes which are divided into two partsthe information part and the next part so searching means finding whether given value is present in the information part of the node or not if it is presentthe algorithm returns the address of the node that contains the value