Single Linked List (Deleting the Node at a Particular Position)

  Рет қаралды 228,935

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 84
@bhavyabhagwani5407
@bhavyabhagwani5407 4 жыл бұрын
This is a blessing to us who are not having any classes to study! Brilliant teaching literally! Also please complete the series, trees graphs and everything
@Jeremyak
@Jeremyak 4 ай бұрын
Neso puts out the highest quality videos I have been able to find on these topics, this is the type of instruction one would expect to find in a college course that you paid too much money for, but in reality it's better than 95% of them. Thank you sir, God bless.
@anshgupta6754
@anshgupta6754 3 жыл бұрын
alternate solution: void delete_node_at_position (struct node* head, int position) { struct node* ptr = head; for(int i=1; ilink; } ptr->link=ptr->link->link; free(ptr->link); ptr=NULL; cout
@XyYz-yc1wh
@XyYz-yc1wh 5 ай бұрын
this wont work you first link the node coming after the node deleted then free that node
@khabibali4967
@khabibali4967 4 жыл бұрын
Sir, Honestly speaking I have no words that I explain your vast knowledge about Data Structure on KZbin But unfortunately, I couldn't find a complete series on data structure
@eva42sh
@eva42sh 2 жыл бұрын
This is the best site to learn Data Structures.
@pulastyadas3351
@pulastyadas3351 4 жыл бұрын
Sir,Please upload double linked list , stack , queue as soon as possible 🙏🙏🙏 this will help us to prepare for placement this year
@nesoacademy
@nesoacademy 4 жыл бұрын
Sure.
@karimabou6493
@karimabou6493 4 жыл бұрын
And also trees please
@sambitmishra129
@sambitmishra129 4 жыл бұрын
@@nesoacademy sir I could able to learn c only bcz of u sir. Plz 🙏 upload the rest of topic of dsa as soon as possible,it will be a great help for students.....❤️ The way you have explained the things nobody can explain that way .very easy & to the point & the example in chapter just brush up the knowledge of the topic to the next level.....sir plz 🙏 🙏 give a lot of examples with explanation to make things more easier..... Thank u sir u r great help ❤️❤️❤️
@Thannila.G-l6b
@Thannila.G-l6b 3 ай бұрын
Thankyou very much sir , without you I can't understand programming.
@mohdarsalan794
@mohdarsalan794 4 жыл бұрын
Please upload daily one video sir.
@nesoacademy
@nesoacademy 4 жыл бұрын
We wish to achieve this kind of upload frequency.
@sambitmishra129
@sambitmishra129 4 жыл бұрын
@@nesoacademy sir please 🙏 try to increase the upload speed that is 1 video per day...
@syedsulaiman8380
@syedsulaiman8380 Жыл бұрын
This channel is HUGLEY underrated
@TECH-ch5dm
@TECH-ch5dm 7 ай бұрын
hey guys i have followed along the whole series, here is the complete code // Online C compiler to run C program online #include #include struct node { int data; struct node *link; }; int print_datan_count(struct node *head){ int count=0; if(head==NULL) printf("Link list is Empty"); struct node *ptr=head; while(ptr!=NULL){ count++; printf("%d ",ptr->data); ptr=ptr->link; } printf(" count=%d",count); } int add_at_end(struct node *head,int data){ struct node *ptr; ptr=head; struct node *temp=malloc(sizeof(struct node)); temp->data=data; temp->link=NULL; while(ptr->link!=NULL){ ptr=ptr->link; } ptr->link=temp; } struct node* add_at_beg(struct node *head,int data){ struct node *ptr=malloc(sizeof(struct node)); ptr->data=data; ptr->link=head; head=ptr; return head; } void insert_pos(struct node *head,int data,int pos){ struct node *ptr=head; struct node *temp=malloc(sizeof(struct node)); temp->data=data; temp->link=NULL; if(pos==1){ printf("Use add_at_beg function"); exit(0); } else{ pos--; for(int i=1;ilink; } temp->link=ptr->link; ptr->link=temp; } } struct node *del_first(struct node *head){ if(head==NULL){ printf("Linked List is Empty"); } else{ struct node *temp=head; head=head->link; free(temp); temp=NULL; } return head; } void *del_last(struct node *head){ if(head==NULL){ printf("Link List is Empty"); } else if(head->link==NULL){ free(head); head=NULL; } else{ struct node* temp=head; struct node* ptr=head; while(temp->link->link != NULL){ temp=temp->link; } free(temp->link); temp->link=NULL; } // return head; } struct node *del_pos(struct node *head,int pos){ struct node *ptr=head; struct node *temp=head; if(head==NULL){ printf("Linked List is Empty"); } else if(pos==1){ head=ptr->link; free(ptr); ptr=NULL; } else{ while(pos!=1){ temp=ptr; ptr=ptr->link; pos--; } temp->link=ptr->link; free(ptr); ptr=NULL; } } int main(){ // Write C code here struct node *head=malloc(sizeof(struct node)); head->data=70; head->link=NULL; struct node *current=malloc(sizeof(struct node)); current->data=60; current->link=NULL; head->link=current; current=malloc(sizeof(struct node)); current->data=40; current->link=NULL; head->link->link=current; //count_nodes(head); add_at_end(head, 64); head=add_at_beg(head,45); insert_pos(head, 444, 6); head=del_first(head); del_last(head); del_pos(head,4); //printf(" "); print_datan_count(head); return 0; }
@Unkn0wn_Legend000
@Unkn0wn_Legend000 4 жыл бұрын
thank U very much sir............ really helped a lot when I had an assignment to submit in 3 hours........
@PrasunNath
@PrasunNath 3 жыл бұрын
Thanks a lot , i was stuck at this topic, now i am completely satisfied, thanks again
@utkarshgupta7517
@utkarshgupta7517 3 жыл бұрын
Pastly watches 3 videos on it but was still not getting, this one has made it clear
@saidhakshan4447
@saidhakshan4447 Жыл бұрын
best linked list tutorials ever.
@krishnakumarjha1236
@krishnakumarjha1236 4 жыл бұрын
Thank you for this. Brilliant as always.
@Ankit-mh1qx
@Ankit-mh1qx 4 жыл бұрын
Pls upload daily & cover whole series of dsa
@ahmettunaergul9598
@ahmettunaergul9598 Жыл бұрын
logic is understandable but writing code is ....
@yashsinghal9748
@yashsinghal9748 4 жыл бұрын
Sir please upload all the videos fastly I am very curious to learn from your videos
@shilpakumari1149
@shilpakumari1149 Жыл бұрын
U r just awesome And your teaching style is best😊
@hi-xu5ee
@hi-xu5ee 4 жыл бұрын
Sir plz upload the remaining portion of the data structures because it is to helpful 🙏🙏🙏🙏🙏
@rahulkumar_317
@rahulkumar_317 4 жыл бұрын
@neso acedmy It is very helpful for us... Please upload the remained topic ..
@dipeshsamrawat7957
@dipeshsamrawat7957 3 жыл бұрын
I love Neso Academy. 💝
@amankumarsingh488
@amankumarsingh488 4 жыл бұрын
But we can also achieve this by using only one pointer instead of current and previous !
@prathyushamiduthur1146
@prathyushamiduthur1146 2 жыл бұрын
then we cannot use that free line right?
@radhikataneja5805
@radhikataneja5805 Жыл бұрын
But with one pointer you only dalete the node for you can't update the previous node link part so for updating the previous node link part you take two pointers
@amankumarsingh488
@amankumarsingh488 Жыл бұрын
First update and then delete.
@adamantiumcookieplayzz4050
@adamantiumcookieplayzz4050 Жыл бұрын
yes you can use one pointer to update like all you need is the [[[[[[current pointer to point to the previous node;so instead of position!=1 put position!=2]]]]]] ie, while(position!=2){ //position!=2 instead of position!=1 to point to previous node. current=current->link; position--; } current->link=current->link->link; but the problem with this is that you have to free up space which is being wasted. so rather do, while(position!=2){ current=current->link; position--; } temp=current->link; current->link=current->link->link; free(temp); temp=NULL; this is recommended as the memory occupied by the rogue node is freed up using the temp pointer. of course so you still need two pointers(temp and current) but inside the while loop you just need one, ie , the current pointer and it should positioned at the node at the previous position to the position where the node is to be deleted.
@kashidislam8229
@kashidislam8229 4 жыл бұрын
sir please complete the datastructure course as early as possible
@revan2580
@revan2580 3 жыл бұрын
node *ptr=head; for(int i=0;ilink; ptr->link=ptr->link->link; Can I do this too?
@rishabhverma5848
@rishabhverma5848 3 жыл бұрын
how will u free the memory and make changes i =1 and i
@pulastyadas3351
@pulastyadas3351 4 жыл бұрын
Much awaited
@MortalKombatTS
@MortalKombatTS 3 жыл бұрын
I didn't understand why we use the double pointer in this fuction, why doesn't it work if we use head like in the other functions?
@bbcbigblackuknowifuknow1148
@bbcbigblackuknowifuknow1148 2 жыл бұрын
we can also do like this bro while (pos-1>1){ ptr=ptr->link; } ptr->link=ptr->link->link; free(ptr->link); I think it is best to not move your head pointer unless it is the only option left
@DaiMoscv
@DaiMoscv Жыл бұрын
Some implementations pass a pointer to pointer parameter to allow changing the head pointer directly instead of returning the new one.
@pulastyadas3351
@pulastyadas3351 4 жыл бұрын
Thanks a lot 🙏🙏🙏 keep uploading
@reverbism
@reverbism 2 жыл бұрын
thank you 9/04/2022 at 6:40 am
@omkarkanase1349
@omkarkanase1349 Жыл бұрын
Thank you
@SurjeetSingh01
@SurjeetSingh01 4 жыл бұрын
why have you stopped updating this series ? we are waiting for your next video , so please continue the course....
@nihalr385
@nihalr385 2 жыл бұрын
It's in their app. You need to pay!
@mr_blaze62
@mr_blaze62 4 жыл бұрын
Thank you so much sir.❤️
@shail0124
@shail0124 2 жыл бұрын
Your del_pos() function could cause segmentation fault if position will be larger than size of List
@raghavachekuri7270
@raghavachekuri7270 4 жыл бұрын
Try to put full course on compiler design also
@tulsigupta117
@tulsigupta117 3 жыл бұрын
Thank you sir
@sowmyar7402
@sowmyar7402 2 жыл бұрын
Thanks a ton sir!
@gamerzbuddies6226
@gamerzbuddies6226 Жыл бұрын
congrats for 2m subs
@rahulsharmaaa
@rahulsharmaaa 4 жыл бұрын
Sir please upload more videos ASAP. pls......
@Nitro-kx7ok
@Nitro-kx7ok 3 жыл бұрын
Thanku sir🔥😍🙏
@sudeepmulumudi
@sudeepmulumudi 3 жыл бұрын
helpful videos ,,,,,do moree
@kevinthomas1618
@kevinthomas1618 3 жыл бұрын
can we use a single pointer instead of two pointers?
@7s9n
@7s9n 4 жыл бұрын
Amazing 💛
@anniamatthews6803
@anniamatthews6803 Жыл бұрын
amazing
@30_vineet17
@30_vineet17 4 жыл бұрын
but sir in this video you showed two programs which program we have to refer to delete a node in singly linked list.
@harshalkumar4538
@harshalkumar4538 3 жыл бұрын
in this video he showed us how to delete a node at a particular position, whereas in previous videos he showed how to delete a node a end or beginning.
@Moukraan
@Moukraan 3 жыл бұрын
thank oyu
@nithinv2969
@nithinv2969 3 жыл бұрын
why can't we use head as one of the parameter instead of double pointer?
@DaiMoscv
@DaiMoscv Жыл бұрын
because we're not returning the head, if we want to change the head we must use double pointer.
@rishabkrishnakumar7446
@rishabkrishnakumar7446 Жыл бұрын
can we also use single pointer.
@accessdenied9393
@accessdenied9393 3 жыл бұрын
We can also do the same task without double pointers: node *delete_at_pos(node *head, unsigned pos) { node *prev = head; node *curr = head; if( !head || pos < 0 || pos < count_nodes() ) { puts("something went wrong"); exit(1); } if (pos == 1) { head = curr->ptr; free(curr); curr = prev = NULL; return head; } while (pos != 1) { prev = curr; curr = curr->ptr; pos--; } prev->ptr = curr->ptr; free(curr); curr = prev = NULL; return head; }
@RORAVIKUMART
@RORAVIKUMART 3 жыл бұрын
it is better to send program link to download
@015_rounakraj9
@015_rounakraj9 4 жыл бұрын
Sir how many lectures it will take more to end single link list. Sir reply please
@AKSHATSINGHKSHATRIYA-r8c
@AKSHATSINGHKSHATRIYA-r8c Жыл бұрын
Hello can someone please explain why are we passing address of head in del_pos function
@kajalmondal9745
@kajalmondal9745 4 жыл бұрын
Jaspreet Sir, i am facing too much problem to tackle the recursion problems. What should i do now please reply? (I watched your all videos related to recursion in c programming playlist)
@Linkario86
@Linkario86 2 жыл бұрын
Does the Garbage Collector delete the unlinked Node in C#?
@shubhammane9563
@shubhammane9563 2 жыл бұрын
sir how position variable gives us position of that particular node
@chinedudaniels2879
@chinedudaniels2879 2 жыл бұрын
hello, what if we passed just *head instead of **head....would it still affect this function?
@DaiMoscv
@DaiMoscv Жыл бұрын
yes it would, since we're not returning the head pointer, the head from the caller would always point to the same node. Note that the returning type is void, so the caller shouldn't update head every time when calling this function. However, by using pointer to pointer, we're actually moving the head pointer itself by reference. It's a same concept with changing variable by reference, instead of passing it as local variable.
@vadigegopinadh2391
@vadigegopinadh2391 3 ай бұрын
1 error generated
@Vineeth_Shankar
@Vineeth_Shankar 4 жыл бұрын
What happens when there is one node in the linked list?
@pallaramkumar
@pallaramkumar Жыл бұрын
int deleteAtCertain(struct node *head,int pos) { struct node *ptr; struct node *temp; ptr=head; int i; for(i=1;ilink; } temp=head; for(i=1;ilink; } temp->link=ptr->link; free(ptr); ptr=NULL; } Is this code good for delete at certain position or not without using double pointer?tell me please
@pritampatil4163
@pritampatil4163 Жыл бұрын
How do u know that u have to delete that 2nd node only how will linked list find that 2nd node
@loganhawkins6486
@loganhawkins6486 3 жыл бұрын
Can you make the code in python? I am trying to implement in a program. Thanks
@animesan3687
@animesan3687 7 ай бұрын
What if position is 5 or somthg greter than 3.
@bhargavsolanki6386
@bhargavsolanki6386 3 жыл бұрын
Still confusion😫
@rasoolknggnt5038
@rasoolknggnt5038 Жыл бұрын
Why is this so much confusing..😭😭 any one give me some tips
@soumyadipadak
@soumyadipadak 4 жыл бұрын
Sir,Please upload doubly linked list , stack , queue,tree ,serching, sorting asap, this will help us to prepare for placement this year
@ritabhsharma6627
@ritabhsharma6627 3 жыл бұрын
Why do we have to use double pointer here....?? Is it possible to do this without using the double pointer...??
@rajeshprajapati6662
@rajeshprajapati6662 2 жыл бұрын
Without using the double pointer ? then i think you need to return head to update it in the main function.
@lavagaming8449
@lavagaming8449 6 ай бұрын
me whos using this to do it to asm :L
Deleting the Entire Single Linked List
6:06
Neso Academy
Рет қаралды 83 М.
Single Linked List (Inserting a Node at a Certain Position)
6:52
Neso Academy
Рет қаралды 331 М.
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 24 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,2 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2,1 МЛН
Reverse a Single Linked List
11:57
Neso Academy
Рет қаралды 281 М.
⚡️NEWS | RUBLE COLLAPSE | STRIKE ON CRIMEA | PUTIN IN KAZAKHSTAN
10:34
Ходорковский LIVE
Рет қаралды 207 М.
Single Linked List (Deleting the Last Node)
5:05
Neso Academy
Рет қаралды 168 М.
Single Linked List (Inserting a Node at the End)
5:49
Neso Academy
Рет қаралды 408 М.
Single Linked List (Deleting the First Node)
3:47
Neso Academy
Рет қаралды 190 М.
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 350 М.
Singly Linked List | Insert, Delete, Complexity Analysis
14:39
Blue Tree Code
Рет қаралды 62 М.
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 24 МЛН