Consider the following node structure –
struct node {
int data;
struct node *next;
}*start = NULL;
struct node *new_node,*current;
Summary of Different Linked List Terms :
Declaration Term | Explanation |
---|---|
struct node *new_node,*current;
| Declaring Variable of Type Node. |
*start = NULL;
| Declared a global variable of type node. “start” is used to refer the starting node of the linked list. |
start->next
| Access the 2nd Node of the linked list. This term contain the address of 2nd node in the linked list. If 2nd node is not present then it will return NULL. |
start->data
| It will access “data” field of starting node. |
start->next->data
| It will access the “data” field of 2nd node. |
current = start->next
| Variable “current” will contain the address of 2nd node of the linked list. |
start = start->next;
| After the execution of this statement, 2nd node of the linked list will be called as “starting node” of the linked list. |
Explanation of Terms :
Consider the above linked list , we have initial conditions –
- “start” node is pointing to First Node [ data = 1 ]
- “current” node is pointing to Second Node [ data = 3 ]
with respect to the above linked list , data will be –
Term | Explanation |
---|---|
current = start->next
| “current” will point to node having data = 3 |
int num = start->data
| “num” will contain integer value “1“. |
int num = start->next->data
| “num” will contain integer value “3“. |
temp = current->next
| “temp” will point to node having data = 5 |
int num = current->data
| “num” will contain integer value “3“. |
int num = current->next->data
| “num” will contain integer value “5“. |
No comments:
Post a Comment