File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Linked List/Circular Linked List Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,36 @@ void insertAfterPos(){
189
189
}
190
190
191
191
void deletePos (){
192
+ int x , i ;
193
+ struct Node * temp , * prev , * last ;
194
+
195
+ printf ("Enter the position to delete : " );
196
+ scanf ("%d" , & x );
197
+
198
+ temp = start ;
199
+ for ( i = 1 ;i != x && temp -> next != start ; i ++ ){
200
+ prev = temp ;
201
+ temp = temp -> next ;
202
+ }
203
+
204
+ if (i != x ){
205
+ printf ("value not found" );
206
+ return ;
207
+ }else if (temp == start ){
208
+ last = temp ;
209
+ while (last -> next != start ){
210
+ last = last -> next ;
211
+ }
212
+
213
+ start = temp -> next ;
214
+ last -> next = start ;
215
+ free (temp );
216
+ }else {
217
+ prev -> next = temp -> next ;
218
+ free (temp );
219
+ }
220
+ }
221
+
192
222
int x ;
193
223
struct Node * temp = start , * prev = NULL ;
194
224
You can’t perform that action at this time.
0 commit comments