Repository navigation
Expand file tree
/
Copy pathlinked_list.cpp
More file actions
89 lines (86 loc) · 1.86 KB
/
Copy pathlinked_list.cpp
File metadata and controls
89 lines (86 loc) · 1.86 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<iostream>
using namespace std;
struct node{
int info;
struct node *next;
};
typedef struct node ND;
ND *Start;
int DV_Check_Null(ND *ptr){
if (ptr == NULL)
return(0);
else return(1);}
ND *Create(ND *ptr){
int flag ;
ND *new_D;
flag=DV_Check_Null(ptr);
if (flag==0)
{
ptr=(ND *)malloc(sizeof(ND));
cin >>ptr->info;
ptr-> next = NULL;
return(ptr);
}
else{
ptr-> next=(ND *)malloc(sizeof(ND));
ptr=ptr->next;
ptr->next=new_D;
new_D->info=10;
new_D->next=NULL;
}
}
void DV_traversal (ND * ptr)
{
if (ptr != NULL)
while(ptr){
cout<< ptr -> info;
ptr=ptr->next;
}
}
ND *DV_Desired_location_inserion(ND *ptr,int value)
{
ND *New_D;
ND *prev;
if(ptr==NULL){
ptr=(ND *)malloc(sizeof(ND));
ptr->info=value;
ptr->next=NULL;
return(ptr);}
else {
while((ptr->info>value)||(ptr->next=NULL))
{
prev=ptr;
ptr=ptr->next;
}
if(ptr-> info <value)
{
prev->next=New_D;
New_D->info=value;
New_D->next=ptr;
return(NULL);
}
}
}
int DV_Desired_location_deletion(ND *ptr, int value)
{
ND * ptr;
ND * prev;
if (ptr == NULL)
return(0);
else{
while(ptr->next!=NULL){
if(ptr->info==value)
{
prev->next=ptr->next;
delete(ptr);
return(1);}
prev=ptr;
ptr=ptr->next;
return(0);
}
}
}
int main()
{
return 0;
}