2.11 Insertion in Doubly Linked List(beginning, end, specific position) | Data Structures

Поделиться
HTML-код
  • Опубликовано: 24 окт 2024

Комментарии • 369

  • @shadowyt1727
    @shadowyt1727 9 месяцев назад +65

    This is 2024 and still this series can teach you better DSA than any BIG Universities colleges or professors.

  • @yashtyagi8040
    @yashtyagi8040 4 года назад +267

    Literally IIT level teaching one of the brilliant teacher I have seen yet thanku so much mam 🤗

  • @amangupta2130
    @amangupta2130 2 года назад +32

    31:35 Third way
    newnode->prev = temp;
    temp->next->prev = newnode;
    newnode->next = temp->next;
    temp->next = newnode;

  • @SpharSarmiento
    @SpharSarmiento Год назад +16

    currently studying data structures in my summer vacation and so far im doing great understanding all the concepts of singly and insertion of doubly linked lists!
    Learning from a great teacher feels like we are learning magic!

  • @contentcreator8541
    @contentcreator8541 2 года назад +65

    My friend said to me that in c or c++ programming linked list is very hard than any topics but when i watch your every lecture i feel that linked list is very easy than others topics.

  • @VishnuvardhanKolasani
    @VishnuvardhanKolasani Год назад +7

    3rd way of inserting
    newnode->next=temp->next;
    temp->next->prev=newnode;
    newnode->prev=temp->next;
    temp->next=newnode;
    thank you mam, because of you i'm able to understand each and every concept clearly.👨‍🎓

  • @Mysteryp7
    @Mysteryp7 4 года назад +36

    *temp logic in create node and *tail logic sounds very similar....
    but best clear and explanation compare to my other youtube videos.
    I think I found my youtube professor. thank you~!

  • @-.-_._--
    @-.-_._-- Год назад +13

    0:10 create
    13:55 insert at beg
    17:17 insert at end
    20:45 at pos

  • @saritakumari-oh8fs
    @saritakumari-oh8fs 4 года назад +8

    Because of you I become developer from QA. Thanks... Best lecture of DSA

  • @jeebasharin9746
    @jeebasharin9746 3 года назад +19

    After your teaching I feel coding is easy in linked list . Thanks mam👍👍👌👌

  • @aasthamurdia6159
    @aasthamurdia6159 4 года назад +11

    I wonder how could anyone dislike your videos.Your video is just amazing ma'am.

  • @aryan20052
    @aryan20052 2 года назад +2

    Maam as you explained in one video where we used prev pointer and temp pointer to insert at a given pos in singly linked list , so i have tried to apply it in doubly linked list using a pointer name save and applied following operation:
    while(inext;
    i++;
    }
    nn->next=save->next; //nn is newnode
    temp->prev=nn;
    save->next=nn;
    nn->prev=save;
    Thank you for explaining everything at such a precise lvl.

  • @usmansadiq2014
    @usmansadiq2014 4 года назад +7

    Pretty Good and Straight Explanation with out confusing students. Thanks.

  • @SharathR-mw2yo
    @SharathR-mw2yo Месяц назад +1

    literally the best teacher that i ever seen... sometimes i thought of sharing this to my lecturers, so that they can learn and will teach to us😂

  • @kavyag6326
    @kavyag6326 2 года назад +5

    You are the "Best" Lecture ever. I had zero knowledge of DSA, but now I am learning a lot from you. Million thanks ma'am😍🤩🥰 Love from Karnataka!!

  • @mbemmerganganal5282
    @mbemmerganganal5282 Год назад +2

    That smile 😄 at the end of the lecture gives a energy to continue learning

  • @aishwaryaghosh4329
    @aishwaryaghosh4329 5 лет назад +60

    I have ds in 3rd sem u have helped me a lot💖

  • @LoveIsLifeTurkishIndia
    @LoveIsLifeTurkishIndia 4 года назад +105

    So , conclusion is , we were declaring temp locally in all function.
    Tail is doing the work of temp , but tail is declared globally .

    • @normalpeople3441
      @normalpeople3441 4 года назад

      Yes

    • @shrutirohila7869
      @shrutirohila7869 3 года назад

      What if I declare temp locally and do the same work using it.. so will it be fine?

    • @normalpeople3441
      @normalpeople3441 3 года назад +3

      @@shrutirohila7869 Yeah or you can declare it globally once and use throughout the program..

    • @shrutirohila7869
      @shrutirohila7869 3 года назад

      @@normalpeople3441ok..thanks

    • @kumarkaustubh6657
      @kumarkaustubh6657 3 года назад +1

      @@shrutirohila7869 there is no need of tail.insertion can e done without tail also

  • @bhargavsai5630
    @bhargavsai5630 10 месяцев назад +1

    She made dsa easier for every student. Thank you madam

  • @ronak._kumar
    @ronak._kumar 3 года назад +1

    Third way:-
    .
    .
    while(Inext;
    }i++;
    newnode->prev=temp;
    newnode->next=temp->next;
    temp->next->prev=newnode;
    temp->next=newnode;
    .

  • @professorpoke
    @professorpoke 2 года назад +3

    insert at beginning & insert at end and delete at beginning & delete at end, are symmetrical. Just switch these terms with one another
    head tail
    next prev

  • @taufiqnarsinghani9939
    @taufiqnarsinghani9939 4 года назад +4

    Insertion after position while(i

  • @GamingHub47751
    @GamingHub47751 3 года назад +3

    you explain it like you sit inside the pc and your the compiler of c++ . i learned so much from your videos thanks for all video

  • @umarawan4055
    @umarawan4055 5 лет назад +5

    Very good explaining mam keep it up thanks much a lot from Pakistan province punjab your smile is very awesome

    • @BatBallBites
      @BatBallBites 4 года назад

      Awan sahib punjab from where ?

  • @jg8742
    @jg8742 4 года назад +8

    Dear mam, please correct me if i am wrong, when i want to insert a node at a positon, can;t we do in this way that we take a extra pointer lets say a, and then while we are traversing , we can keep our condition for while loop as i NEXT = new_node, new_node -> prev = a new_node-> next = temp, new_node -> data = data. Please correct me if i am wrong

    • @bigk2367
      @bigk2367 3 года назад +1

      that's what mam said in video you can take another pointer if you want! But this don't do anything except increasing the space of program.

  • @bhavesh7162
    @bhavesh7162 Месяц назад

    Watching 2024 September before one month exam still can't find any better explanation than these
    A sincere gratitude to you 🙏 mam

  • @sggffdgcx3769
    @sggffdgcx3769 3 года назад +15

    After Jenny teaching these concepts, we repeat the coding before her😂

  • @thinesht3634
    @thinesht3634 2 года назад

    Your teaching way is very super mam, it's very amazing . I don't have a staff like yours.

  • @ShrewdRam
    @ShrewdRam 4 года назад +2

    The way of explaining is nice...keep rocking ☺️

  • @ZeeshanAli-yp3wo
    @ZeeshanAli-yp3wo 3 года назад

    Your concepts are much more helpful dear....
    Love from Pakistan....

  • @kanavghai887
    @kanavghai887 5 лет назад +10

    doubly linked list made easy !

    • @tarunaswini6709
      @tarunaswini6709 4 года назад

      Data Structures and Algorithms made easy ----> by Jenny Ma'am . ♥️♥️♥️

  • @Ary2345
    @Ary2345 4 месяца назад +1

    A genuine advise for newbies...if you haven't watch single linked implementation and insertion at different places video .... first watch that. Then it would be too easy to you to get the logic. Then you would also know that you can use temp instead of tail and won't be confused.
    Go watch the single linked list implementation first 🙏🏻👍🏻

  • @KavyaPotnuru
    @KavyaPotnuru 5 месяцев назад

    Mee teaching very efficient gaa vundi mam

  • @hashbitfam
    @hashbitfam 5 лет назад +8

    love the way of your teaching! Damn Crush..💖 Love from Pakistan... Peace

  • @nazirshams6040
    @nazirshams6040 3 года назад +3

    thank you so much for this video.But there was no difference in the temp and tail pointer(temp pointer used in your earlier lacture)

  • @kirtikhohal5025
    @kirtikhohal5025 2 года назад +4

    Also in the insertafterpos we should include the part if (pos==size) , i.e, the node will be added in the last position and we have to change our tail pointer.

    • @sandip_kanzariya8476
      @sandip_kanzariya8476 Год назад +4

      We need to put condition
      else if (pos == Size_Of_LL){
      InsertAtEnd();
      }
      I hope it is helpful

  • @006daredevil
    @006daredevil 2 года назад +1

    There is a mistake in while loop of insert after position. Instead of while(i

    • @ayushmittal9666
      @ayushmittal9666 Год назад

      No there is no need for equal sign in the condition. You can dry run and then check

  • @anonymousfan9703
    @anonymousfan9703 2 года назад

    Because I know Somewhere deep down in my heart I still love you
    Love ur videos

  • @mahimsd7645
    @mahimsd7645 5 лет назад +6

    Happy Janmanshtami....
    God bless you !!!!

  • @Babalicious_babina
    @Babalicious_babina 5 месяцев назад

    Nice explanation.....aapke jaise professors kyu nhi hote college m....😢😢

  • @siddharthdangwal6174
    @siddharthdangwal6174 2 года назад

    great lectures for cs students thanks a lot
    better quality lecture than university professor

  • @professorprasam
    @professorprasam 3 года назад +3

    YES!! Their is one another way without using the concept of double pointer. Which is -
    updating the value of temp i.e
    temp = newnode -> next ;
    newnode of next containing the value of nextnode i.e 200 so, temp = 200.
    Then, updating the value of temp of prev i.e
    temp -> prev = newnode ;
    new node containing 500. So, 500 assign to the temp of prev.
    If my logic is RIGHT please reply me .Thank you.

  • @schoolofyourtalent
    @schoolofyourtalent 4 года назад +3

    31:37
    3rd way
    temp=newnode->next;
    temp->prev=newnode;

  • @savaliyanisargrameshbhai8922
    @savaliyanisargrameshbhai8922 5 лет назад +4

    Fabulous way of teaching 👌👌👏👏

  • @Akashkumar_12
    @Akashkumar_12 Год назад

    Mam teaches very nice and best understanding

  • @ratikantabiswal8053
    @ratikantabiswal8053 2 года назад

    Excellent Way of Explanation

  • @BATOOL_KHAN123
    @BATOOL_KHAN123 11 месяцев назад +1

    Thank you sooo much ma'am ❤❤
    Really appreciate ❤

  • @aqsazahoor681
    @aqsazahoor681 4 года назад +3

    Thanks a lot mam
    You are amazing mashallah Allah bless you 😊

  • @madhushreekulkarni9866
    @madhushreekulkarni9866 3 года назад +1

    Thankyou so much! your efforts in teaching reduces our effort in studying.

  • @sandip_kanzariya8476
    @sandip_kanzariya8476 Год назад +1

    Thanks mam !
    InsertAfterPos me
    else if (pos == size_of_ll){
    InsertAtEnd();
    }
    because we need to update tail also.

  • @samirhusain1685
    @samirhusain1685 5 лет назад +2

    Thank You ma'am ! Please keep making videos,

  • @sajadch6526
    @sajadch6526 4 года назад +8

    mam can we insert node without using the tail like we done in single linked list by making some logical change by our own

    • @sakthivigneshvar4428
      @sakthivigneshvar4428 4 года назад +1

      You can but time complexity will be O(n)

    • @LP-ih2ye
      @LP-ih2ye 4 года назад +1

      @@sakthivigneshvar4428 so how you will implement tail pointer at the end of the linked list?
      Then you have to traverse from head to end again

    • @sakthivigneshvar4428
      @sakthivigneshvar4428 4 года назад

      @@LP-ih2ye No need to traverse, you can simply make tail's next as newnode and that newnode as tail, which is why it is O(1)

    • @LP-ih2ye
      @LP-ih2ye 4 года назад

      @@sakthivigneshvar4428 if you don't mind can you please write the code of inserting at end 🙂?

    • @sakthivigneshvar4428
      @sakthivigneshvar4428 4 года назад +1

      @@LP-ih2ye Yeah ok, for doubly linked list:
      newnode->next = 0;
      newnode->prev = tail;
      tail->next = newnode;
      tail = newnode;
      For singly linked list, just write:
      newnode-next = 0;
      tail-next = newnode;
      tail = newnode;

  • @KandulaAsrith
    @KandulaAsrith 2 года назад

    Mam simply traverse the temp through the newly created node
    temp=temp->next;
    temp=temp->next;
    Now write
    temp->prev=newnode

  • @abrarlasebai405
    @abrarlasebai405 4 года назад +1

    شكرا جزيلا لك

  • @jaganiabhisheknavab7954
    @jaganiabhisheknavab7954 2 года назад

    Literally excellent explain and teaching good

  • @preethilatadanguria6946
    @preethilatadanguria6946 2 года назад

    Newnode->prev=temp;
    Newnode->next=temp->next;
    Temp->next->prev=newnode;
    Tempo>next=newnode;

  • @roohullahroohani5383
    @roohullahroohani5383 2 года назад

    Mam, may Aap sy bhot pyar krta hun, hrrat ap ki awaz sun k sota hun. love from AFGHANISTAN

  • @parthmaheta6373
    @parthmaheta6373 3 года назад +1

    In another way at insert atpos()
    temp = newnode->next ;
    temp->prev = newnode

  • @akhil1324
    @akhil1324 3 года назад

    It's help me most in Ds .👍

  • @piyushpathak7311
    @piyushpathak7311 5 лет назад +4

    Mam plz make videos on time complexity..

  • @tarunrkumar2756
    @tarunrkumar2756 3 года назад

    explained so smoothly , thank you ma'am

  • @pradumansharma4569
    @pradumansharma4569 4 года назад +2

    You make linkedlist like halwa.
    No one can teach like u, special on youtube

  • @WebDude
    @WebDude 5 лет назад +9

    If you guys are watching the videos in series, then start this video at 14:00, till then previous lecture has been repeated only.

    • @sahilprasantachoudhury911
      @sahilprasantachoudhury911 5 лет назад

      Actually she has explained about the use of tail pointer till this which wasn't mentioned earlier

    • @biswajitsahoo1456
      @biswajitsahoo1456 4 года назад +2

      @@sahilprasantachoudhury911 but I think that tail and temp has a lot similarity in them...

    • @sahilprasantachoudhury911
      @sahilprasantachoudhury911 4 года назад +1

      @@biswajitsahoo1456 yes,but it's better to get all the steps clarified right?

  • @spandandhar3884
    @spandandhar3884 4 года назад +1

    Mam, when we are inserting at the end ,we are traversing the whole linkedlist ,so why time complexity would be O(1)???

  • @kkushboo5770
    @kkushboo5770 Год назад

    Really excellent explanation mam

  • @chanduyadav7037
    @chanduyadav7037 2 года назад

    Else if(pos>length (head)) {
    Pf("length exceeded");
    }

  • @shanmukhtalluri6189
    @shanmukhtalluri6189 4 года назад +4

    Mam please show us the total compilation and output in a code editor and make a seperate video because while typing code myself it is not executing at all. Please 🙏😭

  • @nateshsingh9968
    @nateshsingh9968 Год назад

    //by creating another pointer. which will be pointing towards temp->next
    void insert_at_pos()
    {
    node *head, *newnode, *temp, *thptr;
    newnode = (node *)malloc(sizeof(node));
    cout newnode->data;
    int pos, i = 1;
    cout pos;
    temp = head;
    while (i < pos - 1)
    {
    temp = temp->next;
    }
    thptr =temp->next;
    temp->next=newnode;
    newnode->prev=temp;
    newnode->next=thptr;
    }

  • @pragnareddymosra5523
    @pragnareddymosra5523 3 года назад +1

    Let take tail as pos +1
    Then
    Newnode->next=temp->next
    Temp->next =newnode
    Newnode->prev=tail
    Tail->prev=newnode

  • @ronak._kumar
    @ronak._kumar 3 года назад +1

    Thankyou so much dearest mam ❤️❤️

  • @sarveshsawant1666
    @sarveshsawant1666 2 года назад +1

    Hello maam,
    I had one doubt regarding head or temp pointer in general. See head, temp or even newnode are of type struct node, so when we declaire them they are pointing to memory location of srtuct node containing space for data, *prev & *next. So when we simply write head = temp = newnode ; then how compiler know that in what pointer space (prev or next ) address of newnode is to be stored . See this doubt arrived with Dll as in SLL there was space for one address only.
    It will be nice if you solve this query
    thank you

  • @jai.shri.ram.3000
    @jai.shri.ram.3000 4 года назад

    ma'am while adding at the end I thought u should also [rovide the code for the data where there is no data in the linked list.
    Thank you for this wonderful video with that much simplicity loved the way of your teaching.

  • @ab756
    @ab756 5 лет назад +3

    Make please make video on time complexity of code

  • @mad.for.videos
    @mad.for.videos 2 года назад

    31:36 third way
    {
    newnode->next =temp;
    newnode->prev=temp->prev;
    temp->next = newnode;
    temp=newnode->prev;
    temp-> = newnode;
    }

  • @hemanshuparmar5005
    @hemanshuparmar5005 Год назад

    ❤thank u so much ma'am....for this great explanation 🪷

  • @shrutiballurgi9651
    @shrutiballurgi9651 5 лет назад +5

    Mam please make videos on C programming .It will be helpful for BE 1st year students.

    • @iverpunayan7308
      @iverpunayan7308 5 лет назад

      this is C programming Structures mam hehehe this is advance

    • @SaumyajeetDas
      @SaumyajeetDas 2 года назад

      @@iverpunayan7308 People say lie C Programming is wonderful until we met Data Structures

  • @Abhishek-od1wp
    @Abhishek-od1wp 4 года назад

    Awesome teaching

  • @foyazunnesamomo8223
    @foyazunnesamomo8223 3 года назад

    Too good, Madam. Thanks a million.

  • @nishitdarji6446
    @nishitdarji6446 2 года назад +1

    is this the third way cause, The very first time i thought of logic was this
    newnode->next = tail
    newnode->prev = temp;
    tail->prev = newnode;
    temp->next = newnode;
    Is this right ?

  • @u_nknown4O4
    @u_nknown4O4 2 года назад

    Mam,Thank you so much.🥰
    Your Explanation is just awesome, i can understand every point and you have cleared every single concepts 🥰
    Best CS teacher i have ever seen.
    Soon we will be a family of 1M subscribers❤️

  • @holyshit922
    @holyshit922 5 лет назад +1

    I found insertion for sorted singly linked list
    I updated tail pointer and connected prev pointers
    and it works for doubly linked list but one of the traversal pointers can be eliminated
    To get rid this extra pointer insert before will be useful
    What cases should we consider when inserting before given node etc

  • @AISHWARIAROYSNIGDHA
    @AISHWARIAROYSNIGDHA 3 года назад

    Very helpful video,thank you ma'am.

  • @yash_14h
    @yash_14h Год назад +2

    Mam this creation with tail is totally same as temp,, only we uses tail instead of temp

  • @Hemashree_Gunasekaran_25
    @Hemashree_Gunasekaran_25 5 месяцев назад

    17:06 insert at beginning
    20:39 insert at end

  • @SuryanshiAgarwal
    @SuryanshiAgarwal 6 дней назад

    in insertion at position you talk about predefined function length but in c i don't think so that there is any predefined function length

  • @bharathys6388
    @bharathys6388 3 года назад

    Mam explain the concept without using tail pointer with program in insertion at end

  • @aryansingh2105
    @aryansingh2105 4 года назад +1

    For Java :
    //function to insert data in doubly linked list(default end)
    public void append(int data) {
    Node node = new Node(data);
    Node temp = head;
    if(head == null) {
    head = temp = node;
    return;
    }
    else {
    while(temp.next != null) {
    temp = temp.next;
    }
    temp.next = node;
    node.prev = temp;
    }
    }
    //function to insert data in start of doubly linked list
    public void push(int data) {
    Node node = new Node(data);
    node.next = head;
    //node.prev = null;
    if(head == null) head = node;
    else {
    head.prev = node;
    node.next = head;
    head = node;
    }
    }
    //function to insert at a given position
    public void insert(int pos, int data) {
    if(pos < 1 && pos > length()) System.out.println("Invalid position to insert.");
    else if(pos ==1) push(data);
    else {
    Node node = new Node(data);
    Node tempNode = head;
    int count = 1;
    while(count < pos-1 && tempNode.next != null) {
    tempNode = tempNode.next;
    count += 1;
    }
    node.prev = tempNode;
    node.next = tempNode.next;
    tempNode.next = node;
    if(node.next != null) node.next.prev = node;
    }
    }

  • @kirtikhohal5025
    @kirtikhohal5025 2 года назад +1

    Also in the insert at pos function we need to separately mention the condition that if position=size +1 , that is the user wants to enter the data at last position, then we have to call the insert at end function, bcoz in this case we need to update the tail pointer also.

    • @susantadey2408
      @susantadey2408 2 года назад

      can you send me the code?

    • @kirtikhohal5025
      @kirtikhohal5025 2 года назад +1

      If (pos==size+1)
      { delfromend();
      }
      The delfromend function that we have written previously will accordingly update the tail pointer.

  • @rahulmuthavarapu4793
    @rahulmuthavarapu4793 5 лет назад +5

    //alternate method
    newnode->prev=temp;
    newnode->next=temp->next;
    temp->next->prev=newnode;
    temp->next=newnode;

    • @aryansingh2105
      @aryansingh2105 4 года назад +1

      @Rahul , I think in 3rd line
      if( temp->next != null) temp->next->prev = newNode;
      should be the case, otherwise it can give null pointer exception.

  • @Vyshali07
    @Vyshali07 2 года назад +1

    mam..
    can we insert at pos=4 intead of writing invalid condition
    else if(pos==count+1)
    {
    insertatend( );
    }

  • @Ayush479
    @Ayush479 4 года назад +2

    Thank you very much for your great explanation on ds algo🤗

  • @ritikabali6466
    @ritikabali6466 3 года назад

    very well explained. thank u so much.

  • @PankajKumar-qb9ic
    @PankajKumar-qb9ic 4 года назад

    Nothing to say ..Just keep it up👏👏👌

  • @akankshaawasthi3932
    @akankshaawasthi3932 4 года назад +2

    While i less than equal to pos -1 we can also write this on after pos.

  • @-AshwithaAlladi
    @-AshwithaAlladi 3 года назад

    Ur explanation is same as ur beautiful face 😍😍 tq mam❤️

  • @vishnuspatel7846
    @vishnuspatel7846 Год назад +1

    we can use temp instead of tail right because the temp is at end. isnt it a right thing

    • @asgaming8363
      @asgaming8363 Год назад

      hi bro can you send me the complete code
      i am facing lot of issue

  • @surajmundada8298
    @surajmundada8298 2 года назад

    last step is temp->next->prev = newnode

  • @manishbande8277
    @manishbande8277 4 года назад

    Nice explanation ....add one more thing in these linklist videos ... how to inset null/ Zero at last node 's next address and to print the entire link list with data , current address and next address

  • @unknownuser-yq6co
    @unknownuser-yq6co Месяц назад

    Why not using tail pointer in insert at pos() to reach last node

  • @sunilpatidar8609
    @sunilpatidar8609 4 года назад +1

    mam can you solve previous year wuestion of linklist ,queue point of gate our logic is not buildup how we can sol wuestion pls reply