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 RUclips ❤❤
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 .
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
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.
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 ✌✌
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
Please do upload it completely, this series is gonna save my life.
One of the best series I have ever watched on RUclips to learn topics related to CSE. Sir, please organise live interaction sessions.
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 RUclips ❤❤
Yes really need this type of content
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 .
Thank you so much sir. I wish you and your family good health and loads of happiness. Thank you again for this wonderful work!
I love Neso Academy :)
gigantic amount of help we are receiving only because of your mindset and your beliefs
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
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.
Thank 🙏💕u sir.
Plz upload the videos fastly...
Sir while loop will be become infinite loop am i right...
much obliged to you sir
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?
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
Thnks a lot for this 🙏🏻🙏🏻🙏🏻
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 ✌✌
Try English.
Hindi aati hogi kya usko?
@@sayemaroyali3100 may be ati ho😁😅
Thank you ❤️
Dear sir,
why do we need to newP=addToEmpty(newP,data).instead of this malloc for newP
sir can we implement this using only one ptr i.e temp only... rather than both temp and temp2?
Yes👍
//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;
}
You explained very well but you didn't discuss any corner cases
at 3:36 shouldn't the prev node fore newP be linked to the next node of the temp?
Whether I want to avoid the newp=addtoempty(newp,data) . What should i write? it will work with temp->data or temp2->data. ?
dear sir,
will you please explain me about doubly linked list using strings?
thank you.
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
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
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
he's using codeblocks
@@harshalkumar4538 thank you so much😊
that's because the sequence of pointer updations is wrong
i didn't understand the part of 'position -- ' any help pls?
which softeware sir used
plzz anyone tell me
Code blocks
@@AishLovesSpaghetti thank you so much😊
me watching night before exam
NewP = addToEmpty(newP , data)
In this line why newP is pass???
bcus the function return value is saved. hence it can be pass by value
🙏🙏🙏🔥
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;
}