Repository navigation
Expand file tree
/
Copy pathca1.cpp
More file actions
92 lines (92 loc) · 1.97 KB
/
Copy pathca1.cpp
File metadata and controls
92 lines (92 loc) · 1.97 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
90
91
92
// #include<iostream>
// using namespace std;
// class Node{
// public:
// int val;
// Node *next;
// };
// Node* create(int val){
// Node* x=new Node;
// x->val=val;
// x->next=nullptr;
// return x;
// }
// void display(Node* t){
// while(t!=nullptr){
// cout<<t->val<<endl;
// t=t->next;
// }
// }
// Node* insertp(int p,int v,Node* t){
// Node* x=create(v);
// if(p==1||t==nullptr){//insertion at beginingingingh
// x->next=t;
// t=x;
// return t;
// }
// Node* k=t;
// for(int i=1;i<p-1;i++){
// k=k->next;
// }
// x->next=k->next;
// k->next=x;
// return t;
// }
// Node* delp(int p,int v,Node* t){
// if(t==nullptr){//insertion at beginingingingh
// return nullptr;
// }
// if(p==1){
// return t=t->next;
// }
// Node* k=t;
// for(int i=1;i<p-1;i++){
// k=k->next;
// }
// k->next=k->next->next;
// return t;
// }
// Node* rev(Node* t){
// Node* prev=nullptr,*cur=t;
// Node* next;
// while(cur){
// next=cur->next;
// cur->next=prev;
// prev=cur;
// cur=next;
// }
// return prev;
// }
// int main(){
// int arr[5]={10,20,30,40,50};
// Node* head=nullptr;
// int i=0;
// if(!head){
// Node* x=create(arr[i]);
// x->next=head;
// head=x;
// i++;
// }
// while(i<5){
// Node* x=create(arr[i]);
// x->next=head;
// head=x;
// i++;
// }
// Node* temp=head;
// head=rev(temp);
// cout<<"reversed the array"<<endl;
// // display(temp);
// head = insertp(4, 100, head);
// // display(head);
// head=delp(4,100,head);
// display(head);
// }
// #include<iostream>
// using namespace std;
// class Node{
// int val;
// Node* next;
// Node(int v):val(v),next(nullptr){};
// };
// //initializer list will initialize the data member in order, so it's importa