2.12 Deletion from Doubly Linked List (beginning,end,specific position) | Data Structures Tutorials

Поділитися
Вставка
  • Опубліковано 7 лис 2024

КОМЕНТАРІ • 176

  • @mdnazisharman0187
    @mdnazisharman0187 4 роки тому +46

    i was about to give up on data structures...
    thank you mam for your superb detailed explanation videos which boosts up motivation and made my interest to learn more and more...
    now i get why these lectures are free, because no one else could afford to buy these priceless lecture..
    thanks a lot mam...

    • @godhaninisarg1570
      @godhaninisarg1570 11 місяців тому +1

      same bro muje samaj hi nhi aa raha tha college me isliye maine soch liya tha DS mere liye nhi hai me kabhi nhi sikh paunga par ma'am ne bacha liya

  • @JennyslecturesCSIT
    @JennyslecturesCSIT  5 років тому +122

    CORRECTION: 1) in both delfrombeg() and delfromend() , we will write one more "if condition" to check if there is only one node in the list:
    if(head==tail)
    { head=tail=0;
    free(temp);
    }
    2) in delfrompos() function , we will check for corner cases:
    if(pos==1)
    { delfrombeg();
    }
    in else part after while loop we will check whether the node you want to delete is last node or not by writing:
    if(temp->next==0)
    { tail=tail->prev;
    tail->next=0;
    free(temp);
    }

    • @nigampratap2466
      @nigampratap2466 4 роки тому +16

      Mam I think we should also have a condition like suppose we want to delete from position number 'm' then we should check from which end it is nearer (from head or tail) accordingly we will traverse from forward or backward. In test cases with large number of nodes this might be become handy

    • @hardikmittal7291
      @hardikmittal7291 4 роки тому +1

      I was just going to ask you the same thing in comments... 😂😂

    • @user-kb9tz7pp9y
      @user-kb9tz7pp9y 3 роки тому

      @@nigampratap2466 wat do u think about using lenght of striing and tail for this case ????

    • @karrran
      @karrran 3 роки тому +1

      in the delfrompos(), after checking the node is last or not.. can we call delfromend() in the if?

    • @kirtikhohal5025
      @kirtikhohal5025 2 роки тому +2

      @@karrran yes we can call delfromend function

  • @Kishorthakre_
    @Kishorthakre_ 3 роки тому +12

    After watching your DS videos, I easily implemented it with Python.
    It's helped me a lot.
    Thanks Ma'am 👍

  • @madhurin5587
    @madhurin5587 4 роки тому +16

    All the concepts are explained beautifully!
    Would you create a " OOPS in Java " complete series too?

  • @ankitakundu4278
    @ankitakundu4278 5 років тому +24

    Thanks a lot maam. Now I can code singly & doubly linked list by my own. I am getting this confidence only because of you ma'am. Maam i have a request, i watched your all sorting algorithm videos, in heap sort you described us only max heap using examples..so I want if you kindly make a video on min heap too..

  • @hamidullah3641
    @hamidullah3641 5 років тому +11

    You are doing so great.... may Allah bless u always

  • @CodingWorld202
    @CodingWorld202 Місяць тому +1

    Mam...U are Just Fire..like what the level of teaching

  • @smiletripathi3839
    @smiletripathi3839 2 роки тому +1

    You explain each and every step in detail.It helps alot to solve the confusion.Thanks a lot for your hardwork.

  • @AbhinavKumar-dr4ef
    @AbhinavKumar-dr4ef 2 роки тому +1

    Salute to you for a clear explanation. God bless you for your hard work Mam.

  • @vaibhavacharya7507
    @vaibhavacharya7507 5 років тому +14

    Hello mam!!!
    You are teaching soo soo soo good...
    I request you to mam for create a video playlist for JAVA and computer architecture.....
    And mam u Forgot To create forward videos of operating system so please mam work on it...
    I hope u will create in soon ...
    Thank u mam...

  • @sunnykumar-dg7gs
    @sunnykumar-dg7gs 5 років тому +19

    Maam u are not allowed to explain so good😅.. This video just cleared all my previous doubts🙂🙂

  • @mujtabasiddiqui
    @mujtabasiddiqui 2 роки тому

    Great Efforts really appreciated thanks a lot first time after 15 years I am touching code and after the video I am able to write the code thanks a lot

  • @akshathole6641
    @akshathole6641 2 роки тому +2

    Mam we need more lectures from this tutorial. The way you have taken values for previous and next make it more easier for us to understand.

  • @AZ-gm9ol
    @AZ-gm9ol Рік тому

    The best explanation which I’ve ever heard.
    Thanks

  • @lokeswaripanchireddi-z6l
    @lokeswaripanchireddi-z6l 7 місяців тому

    Mam after listening your DSA videos,I got interest on learning CSE
    Thank u very much mam😊

  • @rahulmuthavarapu4793
    @rahulmuthavarapu4793 5 років тому +10

    \\alternate method
    delfromend()
    :
    temp=tail;
    tail=temp->prev;
    tail->next=0;
    temp->prev=0; \\or (free(temp));

  • @vaibhavnigam6497
    @vaibhavnigam6497 4 роки тому +1

    Ma'am your explanation technic is mind blowing that is very suitable for anyone new to learn....
    your idea of imparting knowledge through such type of tutorials is admirable.
    you are one of teacher who is teaching with clearing concept as well as genuine n deep points...
    These r helping me a lot.
    Thanq so much.

  • @akbarahmad5245
    @akbarahmad5245 5 років тому +2

    No doubt, there are some other teachers who are teaching Data Structure but mam the attribute which separates you from them is that you also teach us coding in Data Structure.
    Thankyou so much mam ;)
    Mam, can you please tell me how to prepare DS, DB, OS, CCNA mcq’s? Any reference mam.

  • @aparnadubey1134
    @aparnadubey1134 5 років тому +1

    Thanks for teach us ds in easy English language..
    Thanks a lot mam..
    Help us always

  • @priyankabharti9150
    @priyankabharti9150 4 роки тому

    Maam ...your explaining technique is owsm ....👌
    And becoz of you only i clear my concept in all the topics in data structure ... 😊🤗 ..and we are very glad that we have teacher like you ...
    Keep it maam god bless you ..🤗

  • @YashSingh-wv3yx
    @YashSingh-wv3yx 3 роки тому

    You are the best teacher and your videos are very knowledgeable!!!👍

  • @edwintjoa6099
    @edwintjoa6099 4 роки тому

    Thank you for a clear explanation on how the doubly linked list works!!

  • @marimuthu_a
    @marimuthu_a 3 роки тому +1

    Hello madam
    At 16:29 , while(I

  • @gayatriborade9556
    @gayatriborade9556 2 роки тому

    Because of you ma'am I am able to clear all my doubts of linked list and now I can code very confidently...Thank you so much ma'am

  • @Yaki-qn3yx
    @Yaki-qn3yx 3 роки тому

    best *lecture -> Jenny's lectures CS/IT NET&JRF

  • @PabloEscobar-vm5oy
    @PabloEscobar-vm5oy 8 місяців тому

    thanks for your superb lectures and also i thanks god for superb bueaty

  • @holyshit922
    @holyshit922 5 років тому +4

    Maybe split linked list (after given node , before given node)
    and concatenation of linked list
    It will be useful for divide and conquer algorithms

  • @medusagaming7001
    @medusagaming7001 3 роки тому

    Thank you very much maam for the dedication in teaching complex topic for students and uploading videos for free. God Bless you!!

  • @hamidullah3641
    @hamidullah3641 5 років тому +2

    Ma'am you are so great

  • @006daredevil
    @006daredevil 2 роки тому +1

    Very Important we should write temp==Null; after free(temp) or else temp pointer will be a Dangling pointer.

  • @badvelisridharreddy1677
    @badvelisridharreddy1677 2 роки тому

    Mam your way of explaining and method of explaining concepts is really awesome and next level 👏👏👏 Very much thanks ro you mam for making these amazing videos for students like us....

  • @priyankababar3566
    @priyankababar3566 3 роки тому

    Thank you so much. U make understand the concept very clearly

  • @ashwinipowar2230
    @ashwinipowar2230 4 роки тому

    Mam you are teaching very good.please create playlist for C Programming lectures so that it will clear basics.

  • @rashid7197
    @rashid7197 3 роки тому

    Understanding DATA STRUCTURES AND ALGORITHMS is difficult but don't worry
    We have Jenny mam .
    she made this as easy to understand

  • @kalam_kadipina_manasu
    @kalam_kadipina_manasu 17 днів тому

    temp=head;
    while(temp->next!=0)
    {
    temp=temp->next;
    }
    temp->prev->next=0;
    free(temp) ;
    Ma'am this code is correct or not for Deleting a node at end of the list in Doubly linked list

  • @creativemarvel4569
    @creativemarvel4569 4 роки тому

    Most helpful video for me and my friends as well.
    Thankyou mam

  • @khushbu6424
    @khushbu6424 2 роки тому +1

    You explain so nicely :)

  • @abhiram6087
    @abhiram6087 4 роки тому

    Your content and explanation is excellent, but it would be great if you guys try to reduce the length of the vedio

  • @varanasiyaswanthshiva3538
    @varanasiyaswanthshiva3538 5 місяців тому

    Mam why not
    "while (i

  • @shivaryanbral
    @shivaryanbral Рік тому

    we can simply free(temp) without using temp->prev=0, because the node will automatically deleted once we use free function to clear the node ..(If I'm not wrong) I've tried this

  • @dnazehar7969
    @dnazehar7969 Рік тому +4

    MAM Please e a dekhna thoda sa alag hai
    #include
    struct node
    {
    int data;
    struct node *next;
    struct node *prev;
    };
    struct node *head,*temp,*newnode;
    int count=0;
    int main()
    {
    int choice;
    while(1){
    printf("Enter choice :
    1.Creat.\t2.insert at start.\t3.Insert at end.\t4.Insert at after location.\t5.Display.\t6.Exit
    ");
    scanf("%d",&choice);
    switch(choice)
    {
    case 1: creat();
    break;
    case 2: insertstart();
    break;
    case 3: insertend();
    break;
    case 4: insertloc();
    break;
    case 5: display();
    break;
    case 6: exit(0);
    break;
    default: printf("wrong choice");
    break;
    }
    }
    }
    void creat()
    {
    newnode = (struct node*) malloc(sizeof(struct node));
    printf("Enter data :
    ");
    scanf("%d",&newnode->data);
    newnode->prev = 0;
    newnode->next = 0;
    if(head==0){
    head = temp = newnode;
    newnode->prev = 0;
    newnode->next = 0;
    count++;
    }
    else{
    temp->next = newnode;
    newnode->prev = temp;
    newnode->next = 0;
    temp = newnode;
    count++;
    }
    }
    void insertstart()
    {
    newnode = (struct node*) malloc(sizeof(struct node));
    printf("Enter data :
    ");
    scanf("%d",&newnode->data);
    newnode->prev = 0;
    newnode->next = 0;
    if(head==0){
    head = temp = newnode;
    }
    else{
    head->prev = newnode;
    newnode->next = head;
    newnode->prev = 0;
    head = newnode;
    }
    }
    void insertend()
    {
    temp = head;
    newnode = (struct node*) malloc(sizeof(struct node));
    printf("Enter data :
    ");
    scanf("%d",&newnode->data);
    newnode->prev = 0;
    newnode->next = 0;
    if(head==0){
    head = temp = newnode;
    }
    else{
    while(temp->next!=0){
    temp = temp->next;
    }
    temp->next = newnode;
    newnode->prev = temp;
    }
    }
    void insertloc()
    {
    int i=1,pos;
    temp = head;
    printf("Enter position :");
    scanf("%d",&pos);
    if(pos==1){
    insertstart();
    }
    else if(pos>count){
    printf("Invalid position!");
    }
    else{
    newnode = (struct node*) malloc(sizeof(struct node));
    printf("Enter data :
    ");
    scanf("%d",&newnode->data);
    newnode->prev = 0;
    newnode->next = 0;
    while(inext;
    i++;
    }
    newnode->prev = temp;
    newnode->next = temp->next;
    temp->next = newnode;
    temp->next->prev = newnode;
    }
    }
    void display()
    {
    temp = head;
    while(temp!=0){
    printf("%d ",temp->data);
    temp = temp->next;
    }
    }

  • @AISHWARIAROYSNIGDHA
    @AISHWARIAROYSNIGDHA 3 роки тому

    Very helpful video,thank you ma'am.

  • @susheelkumar7029
    @susheelkumar7029 5 років тому +1

    Thank you for this well explained video

  • @abhimanyugaur1046
    @abhimanyugaur1046 2 роки тому +1

    for deletion at beginning is this logic correct?
    temp=head
    head-=head->next
    head->previous = null
    free(temp)

    • @kriti4698
      @kriti4698 2 роки тому

      yes it seems like

    • @harshilpatel3205
      @harshilpatel3205 Рік тому

      Yes it's almost correct but you have to write one more condition for temp(1st node which you have to delete) because temp->next part has the value of head(2nd node after update) so you have to null that part too.
      Condition is : temp->next=0;
      Now you can free that temp node ...
      Free(temp)..

  • @gargaarohi
    @gargaarohi 4 роки тому

    Thank You ma'am for this lecture

  • @sasikirankakara3773
    @sasikirankakara3773 5 років тому +1

    Nice Teaching Mam!

  • @arshadazath5080
    @arshadazath5080 Рік тому

    Thank you so much ma'am

  • @akashshah8866
    @akashshah8866 Рік тому

    Please make a video on merge sort

  • @ramitbhattacharjee7485
    @ramitbhattacharjee7485 3 роки тому

    Mam we have to set temp->next=0.. Otherwise temp will connected with the next node as a singly linked list.. Ri8??

  • @snehamareddy1867
    @snehamareddy1867 4 роки тому

    Simply super mam

  • @shubhamgurav9194
    @shubhamgurav9194 2 роки тому

    Thanks a lot ma'am 🔥🔥💯💯👍

  • @holyshit922
    @holyshit922 5 років тому +1

    In function delfrombeg()
    Suppose we have only one node on the list
    you did not update tail pointer
    We can have dereferencing of null pointer in head->prev = 0;
    In function delfromend()
    Suppose we have only one node on the list
    you did not update head pointer
    In function delfrompos()
    check your edge cases

  • @ferreira0717
    @ferreira0717 4 роки тому

    Me gusta como explicas ! Saludos desde colombia.

  • @gamingwithpj8572
    @gamingwithpj8572 4 роки тому

    ty mam programs made so easy 💕💕

  • @patnamvivek2406
    @patnamvivek2406 3 роки тому

    Really thank you so mucn madam

  • @GraphicalBoss
    @GraphicalBoss 3 роки тому

    Great job! Thank you and God bless 🙏 🕊✝️

  • @varuniiit4743
    @varuniiit4743 Рік тому

    Guys without using temp, I think we can free memory of nodes using head or tail pointers themselves right?? in case of deletion at begin and end.

  • @muhammadaiman2674
    @muhammadaiman2674 4 роки тому

    thankyou maam, this is very helpful

  • @vinaypratap620
    @vinaypratap620 3 роки тому +1

    Mam this code will work when only one node in the list ???

  • @PRANESHJANA
    @PRANESHJANA 2 місяці тому

    If I insert 8 elements ,and if I delete the 8th element I'm losing the last 2 elements or my program gets stopped,please clarify my doubt and reply asap Mam 🙏

  • @dr.tanishmandhan3882
    @dr.tanishmandhan3882 29 днів тому

    ❤thank u mam from deep of my heart, ur like a goddess

  • @taufiquepathan2303
    @taufiquepathan2303 3 роки тому

    Mam really I appreciate your knowledge you are so good mam.Mam I copy your code but in doubly linked list deletefromend function is not true I am getting error

  • @Rahul.r.r_p
    @Rahul.r.r_p 11 місяців тому

    Day 16 completed

  • @kanavghai887
    @kanavghai887 5 років тому +2

    inspirational stuff!

  • @Vister7713
    @Vister7713 4 роки тому

    Explain the procedure of inserting an element after the specified position of the doubly linked list and also write the program for that operation.

  • @heman6570
    @heman6570 Рік тому

    Is it mandatory to free any node after unlinking

  • @somilsaxenamusicworld8053
    @somilsaxenamusicworld8053 4 роки тому

    My favourite mam I request to cover linked list all questions especially which is on geeks for geeks and if u want put this is in paid promotion of ur rs 59 but plz post it

  • @huycao8521
    @huycao8521 4 роки тому

    Hello Mrs ! Can I use delete in stead of free if I am using C++ ? Thank you very much

  • @__Kuch_Bhi___
    @__Kuch_Bhi___ 5 місяців тому

    👍🙂 very nice video

  • @Praxss
    @Praxss 4 роки тому

    Nicely explained 👍🏻

  • @poojachitalkar9245
    @poojachitalkar9245 4 роки тому

    Thank you so much mam 😘😘

  • @holyshit922
    @holyshit922 5 років тому +2

    Deletion would be easier with search function (Delete node with given key value)

  • @amantyagi6057
    @amantyagi6057 4 роки тому

    Before deallocate or free the required node should we store the data of this node or not.

  • @jaimeguerrero4677
    @jaimeguerrero4677 4 роки тому

    you are amazing teacher thank you it helped me a lot

  • @sggffdgcx3769
    @sggffdgcx3769 3 роки тому

    Ma'am can we write it like
    Temp=tail
    Tail->next=0
    Free(temp)

  • @codehypee
    @codehypee Рік тому +2

    //deletion in doubly linked list
    #include
    #include
    struct node{
    int data;
    struct node *prev,*next;
    };
    struct node *head=NULL,*temp,*tail,*newnode;
    // display function
    void display() {
    temp = head;
    while (temp != NULL) {
    printf(" %d\t ", temp->data);
    temp = temp->next;
    }
    }
    // deletion from beg;
    void delbeg(){
    if(head == tail){
    head=tail=0;
    free(temp);
    }
    else{
    temp=head;
    head = head -> next;
    head -> prev = 0;
    free(temp);
    }
    printf("Updated doubly ll: ");
    display();
    }
    void delend(){
    if(head == tail){
    head=tail=0;
    free(temp);
    }
    else{
    temp=tail;
    tail = tail -> prev;
    tail -> next = 0;
    free(temp);
    }
    printf("Updated doubly ll: ");
    display();
    }
    int getlength(){
    int length=0;
    temp=head;
    while(temp!=NULL){
    temp=temp->next;
    length++;
    }
    return length;
    }
    void delatpos(){
    int pos,i=1;
    int len=getlength();
    printf("Enter position: ");
    scanf("%d",&pos);
    if(pos>len || posprev->next = temp->next;
    temp->next->prev = temp -> prev;
    free(temp);
    printf("Updated doubly ll: ");
    display();
    }
    }
    int main(){
    int choice = 1;
    while(choice){
    newnode = (struct node*)malloc(sizeof(struct node));
    printf("Enter data: ");
    scanf("%d",&newnode->data);
    newnode->next = NULL;
    newnode->prev = NULL;
    if(head == NULL){
    head=tail=newnode;
    }
    else{
    tail->next=newnode;
    newnode->prev=tail;
    tail=newnode;
    }
    printf("Do you want to continue press 1 otherwise 0: ");
    scanf("%d",&choice);
    }
    printf("Values of Doubly ll: ");
    display();
    printf("
    Press 1 to delete a node in the beginning, 2 to delete a node at the end, and 3 to delete a node at a given position: ");
    scanf(" %d",&choice);
    switch (choice){
    case 1:
    delbeg();
    break;
    case 2:
    delend();
    break;
    case 3:
    delatpos();
    break;
    default:
    printf("Input not valid.");
    }
    return 0;
    }

  • @susheelkumar7029
    @susheelkumar7029 5 років тому +2

    M'm please, make video on stack &queue,

  • @arunabhachatterjee9979
    @arunabhachatterjee9979 Рік тому +1

    mam from this code the last node is not deleted

  • @dhanalaxmi5066
    @dhanalaxmi5066 2 роки тому

    Tnq so much mam

  • @shabbarrizvi6494
    @shabbarrizvi6494 3 роки тому

    what a explanation

  • @kunalgajare4011
    @kunalgajare4011 3 роки тому

    very helpful

  • @techyink5344
    @techyink5344 Рік тому

    ty ma'am

  • @yourstudy_guide.
    @yourstudy_guide. 2 роки тому

    Thank you sooo much mam ❤️

  • @AnushaYadav01
    @AnushaYadav01 4 роки тому

    Can we write in this way for deleting a node in the end
    Logic part
    While (temp->next!=NULL)
    {
    temp=temp->next;
    temp->prev->next=NULL;
    }

  • @shivalikurmi7629
    @shivalikurmi7629 3 роки тому

    Here , won't we write choice for continue??if yes,then where ??

  • @samadritamukherjee6198
    @samadritamukherjee6198 3 роки тому

    can you do deletion from before and after a node i am having problem doing those

  • @be_like_gentelman9098
    @be_like_gentelman9098 Рік тому

    deletion @ end
    // its else condition statement
    else
    {
    tail -> prev=temp;
    temp ->next=NULL;
    free(tail);
    tail=temp;
    }
    it's possible

  • @sarthakjoshi21
    @sarthakjoshi21 2 роки тому +1

    mam pls show full coderunning in editor so that i know where i did mistake

  • @nikeshparajuli6345
    @nikeshparajuli6345 4 роки тому

    thanks a lot maam .

  • @arunvijay2279
    @arunvijay2279 4 роки тому

    can i do this is using only temp pointer alone mam?

  • @naimeimran3247
    @naimeimran3247 2 роки тому

    Thanks mam

  • @beastslayer5893
    @beastslayer5893 Рік тому

    mam why are u assigning i=1 in all the lectures by default in c programming the indexing start from 0 to n-1 so u have to assign i=0 .. to start traversing from zero index until pos-1 is achieved ...

    • @ayushmittal9666
      @ayushmittal9666 Рік тому

      It's upto you you can set i =0 i.e. you are referring the first node as position 0 and then you can change the condition accordingly

  • @shubhamdhami6519
    @shubhamdhami6519 2 роки тому

    maam if we free temp then how we traverse the linklist??

  • @ananyathakur0410
    @ananyathakur0410 4 роки тому

    Mam,i have a ques ..The way we use tail pointer in the doubly link list can we use it in singly link list also.

    • @priyankapanore
      @priyankapanore 4 роки тому

      softwareengineering.stackexchange.com/questions/301862/should-linked-lists-always-have-a-tail-pointer

  • @hometvfirestick
    @hometvfirestick 3 роки тому

    thanks

  • @gaurav.89
    @gaurav.89 4 роки тому

    Mam pleasee explain tail pointer in del from end. How it is storing, how we are accessing it.
    Please Explain

  • @here4u25
    @here4u25 3 роки тому

    Mam in deletion for any position can we traverse tha list from tail side also? because nodes has double links ..can we mam?

  • @manikandan7296
    @manikandan7296 2 роки тому

    mam how did you initialize tail.
    we cannot initialize tail to 0 like head .
    how did you know the last element address to store that in tail

  • @houba1263
    @houba1263 4 роки тому +1

    how can we simplfy temp->prev->next plz can i write in a different way?

    • @nitalisondkar6321
      @nitalisondkar6321 4 роки тому

      Yes.....I was also thinking of that only becz this is easy as compare to that

  • @xxsebaignacioxxgomez5019
    @xxsebaignacioxxgomez5019 3 роки тому

    question how can you delete a node from its data? in my case, I need to set data as an artists and ask the user to input an artist name, if that name coincides with any data or value of the node, delete it .
    Thank you so much!