CHP 4 Linked List - New UPDATED
CHP 4 Linked List - New UPDATED
Linked List:-
1. Linked list can be defined as collection of objects called nodes that are
randomly stored in memory.
2.A node contains two fields i.e., data field & address field. Address field
contains the address of successor (next node).
Data Address
NODE
4.Example:-
Data address
Head Tail
12 14 16 NULL
(End of List)
Node
1. Terminology
Ans:- 1.Node:- The structure combination of data and it’s address to the next
structure is called as node.
4.Information:- The data stored in data field of the linked list structure.
5.Null Pointer:- It signifies the end of linked list when the next pointer points to
null.
struct node
int data;
}node;
Assumption:
step 1: start
step 4: Initialize pointer temp with the address from start pointer.(
otherwise
otherwise
step 8: stop
Step 6: Free q.
Step 5: store NULL value in address field of second last node (temp->next).
Step 6: Free q
1) Initialize count as 0
b) count++;
4) Return count
Else
temp-> info=data
temp-> next=start
5. Start=temp
6. stop
void create_list(int);
void addatbeg(int);
void display();
struct node
{
int info;
struct node *next;
}*start=NULL;
void main()
{
int m;
clrscr();
printf("enter data value\n");
scanf("%d",&m);
create_list(m);
printf("enter data value\n");
scanf("%d",&m);
3. q= start
else
temp-> info=data
temp-> next=null
7. q->next= temp
8. stop