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

  Рет қаралды 207,123

Neso Academy

Neso Academy

3 жыл бұрын

Data Structures: Deleting the Node of a Singly Linked List at a Specified Position.
Topics discussed:
1) C program to delete the node of a singly linked list present at a particular position.
C Programming Lectures: goo.gl/7Eh2SS
Follow Neso Academy on Instagram: @nesoacademy(bit.ly/2XP63OE)
Follow me on Instagram: @jaspreetedu(bit.ly/2YX26E5)
Contribute: www.nesoacademy.org/donate
Memberships: bit.ly/2U7YSPI
Books: www.nesoacademy.org/recommende...
Website ► www.nesoacademy.org/
Forum ► forum.nesoacademy.org/
Facebook ► goo.gl/Nt0PmB
Twitter ► / nesoacademy
Music:
Axol x Alex Skrindo - You [NCS Release]
#DataStructuresByNeso #DataStructures #LinkedList #SingleLinkedList

Пікірлер: 84
@bhavyabhagwani5407
@bhavyabhagwani5407 3 жыл бұрын
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
@krishnakumarjha1236
@krishnakumarjha1236 3 жыл бұрын
Thank you for this. Brilliant as always.
@Jeremyak
@Jeremyak 18 күн бұрын
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.
@khabibali4967
@khabibali4967 3 жыл бұрын
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
@PrasunNath
@PrasunNath 3 жыл бұрын
Thanks a lot , i was stuck at this topic, now i am completely satisfied, thanks again
@asaadhabibkhan8420
@asaadhabibkhan8420 3 жыл бұрын
thank U very much sir............ really helped a lot when I had an assignment to submit in 3 hours........
@eva42sh
@eva42sh 2 жыл бұрын
This is the best site to learn Data Structures.
@shilpakumari1149
@shilpakumari1149 Жыл бұрын
U r just awesome And your teaching style is best😊
@pulastyadas3351
@pulastyadas3351 3 жыл бұрын
Much awaited
@pulastyadas3351
@pulastyadas3351 3 жыл бұрын
Thanks a lot 🙏🙏🙏 keep uploading
@saidhakshan4447
@saidhakshan4447 Жыл бұрын
best linked list tutorials ever.
@rahulkumar_317
@rahulkumar_317 3 жыл бұрын
@neso acedmy It is very helpful for us... Please upload the remained topic ..
@dipeshsamrawat7957
@dipeshsamrawat7957 3 жыл бұрын
I love Neso Academy. 💝
@Ankit-mh1qx
@Ankit-mh1qx 3 жыл бұрын
Pls upload daily & cover whole series of dsa
@syedsulaiman8380
@syedsulaiman8380 Жыл бұрын
This channel is HUGLEY underrated
@utkarshgupta7517
@utkarshgupta7517 2 жыл бұрын
Pastly watches 3 videos on it but was still not getting, this one has made it clear
@hi-xu5ee
@hi-xu5ee 3 жыл бұрын
Sir plz upload the remaining portion of the data structures because it is to helpful 🙏🙏🙏🙏🙏
@pulastyadas3351
@pulastyadas3351 3 жыл бұрын
Sir,Please upload double linked list , stack , queue as soon as possible 🙏🙏🙏 this will help us to prepare for placement this year
@nesoacademy
@nesoacademy 3 жыл бұрын
Sure.
@karimabou6493
@karimabou6493 3 жыл бұрын
And also trees please
@sambitmishra129
@sambitmishra129 3 жыл бұрын
@@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 ❤️❤️❤️
@kajalmondal9745
@kajalmondal9745 3 жыл бұрын
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)
@yashsinghal9748
@yashsinghal9748 3 жыл бұрын
Sir please upload all the videos fastly I am very curious to learn from your videos
@ahmettunaergul9598
@ahmettunaergul9598 9 ай бұрын
logic is understandable but writing code is ....
@mr_blaze62
@mr_blaze62 3 жыл бұрын
Thank you so much sir.❤️
@7s9n
@7s9n 3 жыл бұрын
Amazing 💛
@gamerzbuddies6226
@gamerzbuddies6226 Жыл бұрын
congrats for 2m subs
@mohdarsalan794
@mohdarsalan794 3 жыл бұрын
Please upload daily one video sir.
@nesoacademy
@nesoacademy 3 жыл бұрын
We wish to achieve this kind of upload frequency.
@sambitmishra129
@sambitmishra129 3 жыл бұрын
@@nesoacademy sir please 🙏 try to increase the upload speed that is 1 video per day...
@sowmyar7402
@sowmyar7402 Жыл бұрын
Thanks a ton sir!
@palashchandradas2622
@palashchandradas2622 Жыл бұрын
Thank you so much.
@tulsigupta117
@tulsigupta117 3 жыл бұрын
Thank you sir
@omkarkanase1349
@omkarkanase1349 Жыл бұрын
Thank you
@kevinthomas1618
@kevinthomas1618 3 жыл бұрын
can we use a single pointer instead of two pointers?
@sudeepmulumudi
@sudeepmulumudi 3 жыл бұрын
helpful videos ,,,,,do moree
@kashidislam8229
@kashidislam8229 3 жыл бұрын
sir please complete the datastructure course as early as possible
@Nitro-kx7ok
@Nitro-kx7ok 3 жыл бұрын
Thanku sir🔥😍🙏
@anniamatthews6803
@anniamatthews6803 Жыл бұрын
amazing
@Moukraan
@Moukraan 3 жыл бұрын
thank oyu
@raghavachekuri7270
@raghavachekuri7270 3 жыл бұрын
Try to put full course on compiler design also
@pritampatil4163
@pritampatil4163 Жыл бұрын
How do u know that u have to delete that 2nd node only how will linked list find that 2nd node
@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 Жыл бұрын
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.
@user-be4ot5du6s
@user-be4ot5du6s Жыл бұрын
Hello can someone please explain why are we passing address of head in del_pos function
@rahulsharmaaa
@rahulsharmaaa 3 жыл бұрын
Sir please upload more videos ASAP. pls......
@rishabkrishnakumar7446
@rishabkrishnakumar7446 11 ай бұрын
can we also use single pointer.
@shubhammane9563
@shubhammane9563 2 жыл бұрын
sir how position variable gives us position of that particular node
@reverbism
@reverbism 2 жыл бұрын
thank you 9/04/2022 at 6:40 am
@anshgupta6754
@anshgupta6754 2 жыл бұрын
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 Ай бұрын
this wont work you first link the node coming after the node deleted then free that node
@shail0124
@shail0124 2 жыл бұрын
Your del_pos() function could cause segmentation fault if position will be larger than size of List
@loganhawkins6486
@loganhawkins6486 2 жыл бұрын
Can you make the code in python? I am trying to implement in a program. Thanks
@015_rounakraj9
@015_rounakraj9 3 жыл бұрын
Sir how many lectures it will take more to end single link list. Sir reply please
@SurjeetSingh01
@SurjeetSingh01 3 жыл бұрын
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!
@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.
@amankumarsingh488
@amankumarsingh488 3 жыл бұрын
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 11 ай бұрын
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.
@Vineeth_Shankar
@Vineeth_Shankar 3 жыл бұрын
What happens when there is one node in the linked list?
@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
@30_vineet17
@30_vineet17 3 жыл бұрын
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.
@animesan3687
@animesan3687 4 ай бұрын
What if position is 5 or somthg greter than 3.
@chinedudaniels2879
@chinedudaniels2879 Жыл бұрын
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.
@user-fx9bp9uu7s
@user-fx9bp9uu7s 10 ай бұрын
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
@Linkario86
@Linkario86 2 жыл бұрын
Does the Garbage Collector delete the unlinked Node in C#?
@soumyadipadak
@soumyadipadak 3 жыл бұрын
Sir,Please upload doubly linked list , stack , queue,tree ,serching, sorting asap, this will help us to prepare for placement this year
@RORAVIKUMART
@RORAVIKUMART 3 жыл бұрын
it is better to send program link to download
@mba2ceo
@mba2ceo 2 жыл бұрын
How RECLAIM HEAP MEMORY ?
@ritabhsharma6627
@ritabhsharma6627 2 жыл бұрын
Why do we have to use double pointer here....?? Is it possible to do this without using the double pointer...??
@rajeshprajapati6662
@rajeshprajapati6662 Жыл бұрын
Without using the double pointer ? then i think you need to return head to update it in the main function.
@bhargavsolanki6386
@bhargavsolanki6386 3 жыл бұрын
Still confusion😫
@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; }
@lavagaming8449
@lavagaming8449 3 ай бұрын
me whos using this to do it to asm :L
@rasoolknggnt5038
@rasoolknggnt5038 11 ай бұрын
Why is this so much confusing..😭😭 any one give me some tips
@TECH-ch5dm
@TECH-ch5dm 3 ай бұрын
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; }
Deleting the Entire Single Linked List
6:06
Neso Academy
Рет қаралды 75 М.
Single Linked List (Inserting a Node at a Certain Position)
6:52
Neso Academy
Рет қаралды 291 М.
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
Useful gadget for styling hair 🤩💖 #gadgets #hairstyle
00:20
FLIP FLOP Hacks
Рет қаралды 10 МЛН
Получилось у Миланы?😂
00:13
ХАБИБ
Рет қаралды 5 МЛН
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 5 МЛН
Reverse a Single Linked List
11:57
Neso Academy
Рет қаралды 250 М.
Single Linked List (Deleting the First Node)
3:47
Neso Academy
Рет қаралды 165 М.
Why The Windows Phone Failed
24:08
Apple Explained
Рет қаралды 220 М.
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 275 М.
Removing an element from a linked list
13:15
CodeVault
Рет қаралды 14 М.
Singly Linked List (Solved Problem 1)
5:01
Neso Academy
Рет қаралды 62 М.
every good programmer should know how to code this data structure (its easy)
21:08
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН