This presentation is prepared for those students which are not understand Linked-list data structure. This presentation is so easy to clear the concept of Linked-list. Thank you
2. Linked-list is a linear data structure, in which one has a data part and the
other is link part or you can say pointer. The combination of data part and
pointer part is called a node.
Node = Data part + pointer part(link part)
Linked-list is a collection of nodes. The pointer variable is used to store the address of
next node.
The last node pointer part must be NULL (φ). (see next page).
Data part pointer part
12 100
3. head
node1 node2 node3
100 200 300
The link part contains the address of next node.
The head is also a pointer variable which is store the address of the
first node. Every linked-list must be one head pointer.
The addresses of node1, node2 and node3 is 100, 200 and 300
respectively.
100
2 200 4 300 4 φ
4. This algorithm is used to traverse (access) each node of the Linked-list.
Step # 1: [ Declaration ]
integer type count 0
structure pointer variable temp type node
Step # 2: [ Assign head address to temp pointer variable]
temp head
Step # 3: [ Starting Loop]
repeat step 4 and step 5 until temp≠ NULL
Step # 4: [ Assigning next node address]
temp temp next
Step # 5: [ Counting nodes]
count count +1
Step # 6: [ Finish]
Exit
5. void Traversal ( )
{
int count= 0;
struct node *temp;
temp= head;
while ( temp!= NULL )
{
temp= temp next;
count++;
}
}
Linked list
Head
100 200 300
100
2 200 4 300 4 φ
Editor's Notes
Name: MANSOOR IQBAL Roll No. 36 Subject: BSCS Semester: 5h
Name: MANSOOR IQBAL Roll No. 36 Subject: BSCS Semester: 5h
Name: MANSOOR IQBAL Roll No. 36 Subject: BSCS Semester: 5h
Name: MANSOOR IQBAL Roll No. 36 Subject: BSCS Semester: 5h