-
Notifications
You must be signed in to change notification settings - Fork 2
/
linkedList.c
56 lines (52 loc) · 951 Bytes
/
linkedList.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *next;
}*head = 0;
int count = 0;
void create()
{
}
void insertAtBeg(int *value)
{
struct node *n = (struct node*)malloc(sizeof(struct node));
n->next = head;
head = n;
}
void insertAtEnd(int *value)
{
struct node *n = (struct node*)malloc(sizeof(struct node));
struct node *temp = head;
while(temp->next)
{
temp = temp->next;
}
temp->next = n;
n->next = 0;
}
void insertAtPostion()
{
int pos,value,i = 2;
if(pos == 1)
insertAtBeg(&value);
else if(pos == count)
insertAtEnd(&value);
else
{
struct node *n = (struct node*)malloc(sizeof(struct node));
n->data = value;
struct node *temp = head;
while(i<pos)
{
temp = temp->next;
i++;
}
n->next = temp->next;
temp->next = n;
}
}
int main()
{
}