Doubly Linked List (Insertion between the Nodes) - Part 1

  Рет қаралды 127,064

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 43
@bertinaagnes73
@bertinaagnes73 4 жыл бұрын
Please do upload it completely, this series is gonna save my life.
@prateekbaheti8236
@prateekbaheti8236 4 жыл бұрын
One of the best series I have ever watched on KZbin to learn topics related to CSE. Sir, please organise live interaction sessions.
@CodeCampus_1
@CodeCampus_1 4 жыл бұрын
Sir please upload all the video of the Ds algo I have to give my semester exam And you really explained too good I am getting all you explained Please upload all topics asap Best Ds lecture on KZbin ❤❤
@zafdell8170
@zafdell8170 4 жыл бұрын
Yes really need this type of content
@balakrishnaprasad8928
@balakrishnaprasad8928 4 жыл бұрын
Please upload the dsa videos as fast as possible because our exams are coming . We know that you are keeping complete efforts on making a video not only video to clear concept .
@mohammedafnanshariff3142
@mohammedafnanshariff3142 Жыл бұрын
Thank you so much sir. I wish you and your family good health and loads of happiness. Thank you again for this wonderful work!
@YashKumar-br5xi
@YashKumar-br5xi 2 жыл бұрын
gigantic amount of help we are receiving only because of your mindset and your beliefs
@vijaygarothaya6673
@vijaygarothaya6673 3 жыл бұрын
This can be done by one more option: Assume doubly link list like below head-> N1 -> N2 -> N3 -> N4 Suppose we need to add NX after N2 1. Traverse thru list to reach N2. Call N2 as currentNode. 2. Add NX between N2 and N3 NX.prev = currentNode NX.next = currentNode.next currentNode.next = NX NX.next.prev = NX
@DILESHCHURIWAL
@DILESHCHURIWAL 4 ай бұрын
We can also do it without temp2 pointer. newP->next = temp->next; temp->next->prev = newP; temp->next = newP; newP->prev = temp; Also we should check the condition if(temp->next==NULL) before this.
@dipeshsamrawat7957
@dipeshsamrawat7957 3 жыл бұрын
I love Neso Academy :)
@tejatej3628
@tejatej3628 4 жыл бұрын
Thank 🙏💕u sir. Plz upload the videos fastly...
@gulabpatel1249
@gulabpatel1249 4 жыл бұрын
Sir while loop will be become infinite loop am i right...
@CodeCampus_1
@CodeCampus_1 4 жыл бұрын
Sir please jaldi upload krdo sara course sem kaa exam dena hai kuch nhi padha hai Poora DS padna hai aur apne sach me kafhi acha explain kiya hai Please jaldi upload kr do whole course ✌✌
@sayemaroyali3100
@sayemaroyali3100 4 жыл бұрын
Try English. Hindi aati hogi kya usko?
@CodeCampus_1
@CodeCampus_1 4 жыл бұрын
@@sayemaroyali3100 may be ati ho😁😅
@siphethonyambi441
@siphethonyambi441 3 жыл бұрын
why not use *head instead of *temp to reduce the number of pointers you're using since head is difined as a local variable inside your function?
@lawn_mower4941
@lawn_mower4941 3 жыл бұрын
you cant change where head is pointing. head must always point to first node, thats why you can only traverse using head and not update
@mohamedimadeddinefaoussi6966
@mohamedimadeddinefaoussi6966 11 ай бұрын
in case the position is out of range , this case should return NULL because we can't add the node in an out of range position
@satyamkumar6469
@satyamkumar6469 2 жыл бұрын
You explained very well but you didn't discuss any corner cases
@madhuritolambe898
@madhuritolambe898 3 жыл бұрын
sir can we implement this using only one ptr i.e temp only... rather than both temp and temp2?
@AnkitYadav-sc2sm
@AnkitYadav-sc2sm 3 жыл бұрын
Yes👍
@AbcnaihauHnahUznnz
@AbcnaihauHnahUznnz 2 жыл бұрын
//insert at any position except last myNode* add_at_any_pos(myNode *head, int data, int pos){ myNode *ptr = NULL; myNode *temp = head; if(pos == 1) add_at_beg(&head, data); else if(pos == (no_of_nodes(head) + 1)) printf("Invalid Position "); else{ ptr = malloc(sizeof(myNode)); ptr->prev = NULL; ptr->data = data; ptr->next = NULL; pos--; // change temp if pos > 2 else below while(--pos){ temp = temp->next; } temp->next->prev = ptr; ptr->next = temp->next; temp->next = ptr; ptr->prev = temp; } return head; }
@aniketmasram6500
@aniketmasram6500 2 жыл бұрын
Thnks a lot for this 🙏🏻🙏🏻🙏🏻
@okenk.6379
@okenk.6379 8 ай бұрын
at 3:36 shouldn't the prev node fore newP be linked to the next node of the temp?
@成成成-b1q
@成成成-b1q Жыл бұрын
much obliged to you sir
@golamkibria4310
@golamkibria4310 Жыл бұрын
Dear sir, why do we need to newP=addToEmpty(newP,data).instead of this malloc for newP
@anishlowanshi7766
@anishlowanshi7766 2 жыл бұрын
Thank you ❤️
@kumarik9027
@kumarik9027 3 жыл бұрын
dear sir, will you please explain me about doubly linked list using strings? thank you.
@ritvikreddy3959
@ritvikreddy3959 Жыл бұрын
hey it is simple just replace the int data to char data[size of string] and use %s while taking the input i.e in scanf
@soumayadahel8989
@soumayadahel8989 3 жыл бұрын
i didn't understand the part of 'position -- ' any help pls?
@tahreemriaz2401
@tahreemriaz2401 3 жыл бұрын
I am using dev c++ i write same code on dev, but something went wrong soo plz tell me which software you use or also if i use dev c++ , so what's i change in my program
@harshalkumar4538
@harshalkumar4538 3 жыл бұрын
he's using codeblocks
@tahreemriaz2401
@tahreemriaz2401 3 жыл бұрын
@@harshalkumar4538 thank you so much😊
@lawn_mower4941
@lawn_mower4941 3 жыл бұрын
that's because the sequence of pointer updations is wrong
@sumyea1009
@sumyea1009 3 жыл бұрын
Whether I want to avoid the newp=addtoempty(newp,data) . What should i write? it will work with temp->data or temp2->data. ?
@ATHULSHA-i9b
@ATHULSHA-i9b 8 ай бұрын
me watching night before exam
@tahreemriaz2401
@tahreemriaz2401 3 жыл бұрын
which softeware sir used plzz anyone tell me
@AishLovesSpaghetti
@AishLovesSpaghetti 3 жыл бұрын
Code blocks
@tahreemriaz2401
@tahreemriaz2401 3 жыл бұрын
@@AishLovesSpaghetti thank you so much😊
@keshavramvishvakarma9100
@keshavramvishvakarma9100 4 жыл бұрын
NewP = addToEmpty(newP , data) In this line why newP is pass???
@duanedsilva
@duanedsilva 4 жыл бұрын
bcus the function return value is saved. hence it can be pass by value
@rockstarCoolz
@rockstarCoolz 2 жыл бұрын
🙏🙏🙏🔥
@Codehatch344
@Codehatch344 3 жыл бұрын
Sir i have written source code same as yours but got an error on codeblocks. Error: Process returned -1073741819 (0xC0000005) execution time : 0.896 s Press any key to continue. nothing is printing on console could you resolve this problem as soon as possible as all the things are exact same and even rechecked three times i am not getting it, I am attaching source code even for your consideration i will wait for your response. #include #include #include struct branch { struct branch* prev; int data; struct branch* next; }; struct branch* inserttoempty(struct branch* head,int data) { struct branch* temp = (struct branch*)malloc(sizeof(struct branch)); temp->prev = NULL; temp->data = data; temp->next = NULL; head = temp; return head; }; struct branch* insertinbeg(struct branch* head, int value) { struct branch* newnode = (struct branch*)malloc(sizeof(struct branch)); newnode->prev = NULL; newnode->data = value; newnode->next = head; head->prev = newnode; head = newnode; return head; }; struct branch* insertatend(struct branch* head,int value1) { struct branch* trav; struct branch* newnode = (struct branch*)malloc(sizeof(struct branch)); trav = head; newnode->prev = NULL; newnode->data = value1; newnode->next = NULL; while(trav->next!=NULL) { trav = trav->next; } trav->next = newnode; newnode->prev = trav; return head; }; struct branch* addbeforepos(struct branch* head,int data,int position) { struct branch* newP = NULL; struct branch* temp = head; struct branch* temp2 = NULL; if(head==NULL) { newP = inserttoempty(newP, data); } int pos = position; while(pos>2) { temp = temp->next; pos--; } if(position==1) { insertinbeg(head,data); } else { temp2 = temp->next; temp->next = newP; temp2->prev = newP; newP->next = temp2; newP->prev = temp; } return head; }; int main() { struct branch* head = NULL; struct branch* ptr; int position = 2; head = inserttoempty(head,45); head = insertinbeg(head ,98); head = insertatend(head,3); head = addbeforepos(head,56,position); ptr = head; while(ptr!=NULL) { printf("%d",ptr->data); ptr = ptr->next; } return 0; }
Doubly Linked List (Insertion between the Nodes) - Part 2
5:09
Neso Academy
Рет қаралды 60 М.
Circular Singly Linked List (Insertion at the Beginning)
5:28
Neso Academy
Рет қаралды 125 М.
When u fight over the armrest
00:41
Adam W
Рет қаралды 31 МЛН
5 Signs of an Inexperienced Self-Taught Developer (and how to fix)
8:40
Doubly Linked List (Deleting the First Node)
3:36
Neso Academy
Рет қаралды 81 М.
Single Linked List (Deleting the Node at a Particular Position)
9:43
Insert / add  a node in Doubly Linked List
9:20
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 126 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 825 М.
When u fight over the armrest
00:41
Adam W
Рет қаралды 31 МЛН