Data Structure

### Insertion at the beginning of the Singly linked lists

```Step 1. Create a new node and assign the address to any node say ptr.
Step 2. OVERFLOW,IF(PTR = NULL)
write : OVERFLOW and EXIT.
Step 4. IF(START = NULL)
ASSIGN NEXT[PTR] = NULL
ELSE
ASSIGN NEXT[PTR] = START
Step 5. ASSIGN START = PTR
Step 6. EXIT

```

### Insertion at the front of list

```void insertion(struct node *nw)
{
struct node start, *previous, *new1;
nw = start.next;
previous = &start;
new1 = (struct node* ) malloc(sizeof(struct node));
new1->next = nw ;
previous->next = new1;
printf("\n Input the fisrt node value: ");
scanf("%d", &new1->data);
}```

### Insertion at the front of list

```/* INSERT A NODE INTO A SIMPLE LINKED LIST AT THE BEGINNING */
# include <stdio.h>
# include <malloc.h>
# include <conio.h>

{
int data;
};

int i;
int number;

/* Function create a linked list */

{

char ch;
start.next = NULL;
node = &start;      /* Point to the start of the list */
i = 0;
fflush(stdin);
printf("\n Input choice n for break: ");
ch = getchar();
while(ch != 'n')
{
node = node->next;
printf("\n Input the node: %d: ", (i+1));
scanf("%d", &node->data);
node->next = NULL;
fflush(stdin);
printf("\n Input choice n for break: ");
ch = getchar();
i++;
}
}

/* Inserting a node */

{
node = start.next;

previous = &start;

new1->next = node ;
previous->next = new1;
printf("\n Input the fisrt node value: ");
scanf("%d", &new1->data);
}

/* Display the list */

{
node = start.next;
printf("\n After Inserting a node list is as follows:\n");
while (node)
{
printf(" %d\t", node->data);
node = node->next;
}
}

/* Function main */

void main()
{
`About Me`