Linear Data Structure 495
int r=6,f*0,n;
clrscr () ;
printf (" In itia l values rear-%d front-% d*,r,f) j
printf ("n How many elements u want to delete : ”);
scanf ("%d”,6n);
while (f<n)
{
queue[f] «NULL;
f++;
printf ( ”
rear«%d front-% d",r,f) j
}
printf (”n Queue elements are : ”);
for ( n«0?n<7;n++)
printf (■ %d ”,queue[n]);
OUTPUT;
Initial values rear=6 front=*0
How many elements u want to delete: 3
rear=6 front=l
rear=6 front=2
rear=6 front=3
Queue elements are: 0 0 0 4 5 6 7
Explanation The above program is the second part of the first program. We have started exactly
from where we ended the last program. The output of the last program is the starting of this program.
The array is initialized with entered values and rear and front are initialized to 6 and 0, respectively.
The user is asked to enter the number of elements to be deleted. The loop is executed for n times
and 0 to n elements of the array are nullified. At every deletion operation the front is shifted to
inside. It is shifted from 0 to 3 when three elements are deleted. The output of the program is easy to
follow.
b) Dynamic implementation: Dynamic implementation is carried out using pointers. By applying
increment operation on a pointer successive locations of memory can be accessed and an element
can be stored in that location. Thus, the series of element can be continued to any number of
elements. The programmer has to keep the starting address of the pointer in which the first
element is stored. Thus, in the same way the numbers can be viewed or altered. Here is a
simple example.
14.18 SINGLE LINKED LIST
In this type of linked list, two successive nodes of the linked list are linked with each other in a
sequential linear manner. Fig. 14.17 describes a single link list. It is like a train in which two successive
bogies are connected. The train is an example of a single linked list.