Single Linked List (Inserting a Node at the End)

  Рет қаралды 426,052

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 130
@vijaysinghchauhan7079
@vijaysinghchauhan7079 4 жыл бұрын
Your way of teaching and presenting makes the subject easy to grasp ✊ and the best 🌟 thing is that you do all this under 6-8 minutes(speaking generally).
@-saltless
@-saltless 4 жыл бұрын
I've tried to figure this out all day. This video is straight to the point and goes thru line by line
@isteak.0023
@isteak.0023 Жыл бұрын
for those who are confused about the part " while (ptr->link != NULL) " and (ptr!=NULL): it would't be (ptr!=NULL) cause during node 3(3000) ,it satisfies the condition (ptr!=NULL ) ,so ptr becomes ptr->link =NULL . So in next part to assign temp in ptr->link first we need ptr .but as it has become NULL (mentioned earlier) simply ptr->link doen't exist anymore. It was my understanding . pardon my english.
@fatimaachbout9284
@fatimaachbout9284 Ай бұрын
but the ptr will not have NULL ever , the NULL will be just in ptr->link , I didn't get it 🥲
@skekramak4725
@skekramak4725 Ай бұрын
same​@@fatimaachbout9284
@ajmalkhaniit
@ajmalkhaniit 4 жыл бұрын
Sir you explain each and everything in such a manner we go to automatically deep of the subject Amazing
@ahmadaklakh6736
@ahmadaklakh6736 Жыл бұрын
Jindagi me pahli bar esa teacher dekha Jo enta difficult chapter ko easy bana Diya thank you so much sir ❤❤❤❤
@iqbalahmed9128
@iqbalahmed9128 4 жыл бұрын
Im d frst student for the lecture.!! Yayyy way to go neso... very well done
@aspiredifferent8085
@aspiredifferent8085 2 жыл бұрын
Kitna aasani se samjha diya sab kuch NESO ACADEMY ke aage koi nahi hai .
@ecea044gauravgogoi7
@ecea044gauravgogoi7 4 жыл бұрын
this is the best channel on youtube , please keep uploading the other data structures after linked list also
@dhananjay9923
@dhananjay9923 2 жыл бұрын
great explaination since morning 8 am im not understanding this inserting and linked list now its 10 pm finally all doubts are clear and now im doing on my vs code
@AishLovesSpaghetti
@AishLovesSpaghetti 3 жыл бұрын
Great Explanation. The function add_at_end can also be created without creating pointer ptr. We can just use head variable in the loop. Some might say that it's not possible because this will change the value in the head variable; however, this won't happen because address in head variable can only be changed inside main function where it was created. Only the copy of the value stored in head (in add_at_end function) is enough to traverse the list. This can be used to reduce the space complexity.
@sallavatsal
@sallavatsal 2 жыл бұрын
Amazing lectures! Thanks a lot Neso Academy and the instructors for making such good content and that too for free! :)
@indanadeevena4597
@indanadeevena4597 Жыл бұрын
Isn't that sooo.....🤩😇 For your teaching...👏👏
@lipsa-rameshsamal8097
@lipsa-rameshsamal8097 5 ай бұрын
No 1 playlist...neso academy ❤
@SatyaPrakash-ol9gv
@SatyaPrakash-ol9gv 4 жыл бұрын
Sir plzz upload stack queue and other parts of ds videos....ur way of explianing and visualization is speechless
@dudefx8971
@dudefx8971 4 жыл бұрын
Hey neso academy! Are you guys fine? You haven't uploaded videos. Hope u guys are doing well!
@nesoacademy
@nesoacademy 4 жыл бұрын
Yes, we're fine. Thank you for asking. We will upload the next lecture today.
@thrivewise1
@thrivewise1 4 жыл бұрын
An in-depth explanation of the linked list concept. Great Work!! I hope you are going to make videos on other data structures too.
@DatasafeWorld
@DatasafeWorld Жыл бұрын
You make difficult concepts sound so easy.
@yuechenxiao4228
@yuechenxiao4228 2 жыл бұрын
Thank you soooo much for sharing this,making learning programming in C much easier(also teaches me to understand indean accent lol
@emperoraurangzeb4616
@emperoraurangzeb4616 2 жыл бұрын
From Where ur actually ?
@Saikrishna.B
@Saikrishna.B Жыл бұрын
*indian
@Lordash234
@Lordash234 3 жыл бұрын
finally someone who explains algorithm
@photolab6712
@photolab6712 Жыл бұрын
superb playlist... best videos on linkedlist
@allinonesomespecial4
@allinonesomespecial4 2 жыл бұрын
These videos make excitement to learn DSA .🎉👍
@mikeorioles
@mikeorioles 3 жыл бұрын
This video is an epiphany. Thank you so much.
@uttamkarmakarece3534
@uttamkarmakarece3534 3 жыл бұрын
You and your teaching skill is awesome sir
@alexander-ud9bs
@alexander-ud9bs Жыл бұрын
you are the best bro thank you for this course
@selfyqueen2605
@selfyqueen2605 2 жыл бұрын
You guys are giving way too good content.thank you so much these lectures are helping me a lot.🙇‍♀🙇‍♀
@dipankar9700
@dipankar9700 4 жыл бұрын
Very easy to understand Thanks sir U r best 😁😁😁😁😁😁
@dipeshsamrawat7957
@dipeshsamrawat7957 3 жыл бұрын
I love Neso Academy. 💝
@harroopsinghgala6405
@harroopsinghgala6405 4 жыл бұрын
First of all, Thanks for such an easy explanation. Can you please upload video lectures on Microprocessors(8085,8086,8251,8259,etc) since we are facing problem in that subject too.
@AbhishekSingh-cu1fe
@AbhishekSingh-cu1fe 3 жыл бұрын
Awesome Teaching Sir!! Superb 😍
@venkyssss495
@venkyssss495 2 жыл бұрын
Thanks a ton team for making these videos :). In fact thanks is a small word for the kind of content you guys produce.
@SimranjeetkaurWarwal
@SimranjeetkaurWarwal 2 жыл бұрын
Big fan of ur voice sir🥰😁
@aniketshivhare601
@aniketshivhare601 4 жыл бұрын
Create a variable which indicate the last node of list named "tail" tail contain adress of the last node of linked list using this approach we don't need to travsel whole list to add the node in the last.
@codingstuff52
@codingstuff52 4 жыл бұрын
love you bro
@kacperos2720
@kacperos2720 3 жыл бұрын
You are a life saver! Thanks
@muhammadzakiahmad8069
@muhammadzakiahmad8069 3 жыл бұрын
Thanku I was struggling doing the same in python but this made it lot easier though in C.
@MrCEO-jw1vm
@MrCEO-jw1vm 8 ай бұрын
Brilliant! Thanks so much!
@gaboneitormiaw
@gaboneitormiaw 3 ай бұрын
thank you so fucking much, after struggling with this for a few days, now i can easily understand what is happening
@GousePeera-r4r
@GousePeera-r4r 5 ай бұрын
Thanks bro 😊
@shubhangishreya1492
@shubhangishreya1492 2 жыл бұрын
Thank you so much , for explaining very clearly. By using pictorial representation ..
@reverbism
@reverbism 2 жыл бұрын
Thank You 4/04/2022 2:47 am
@johnjohn7795
@johnjohn7795 2 жыл бұрын
Damn good explanation ....love it ❤️❤️
@vishalmpj9485
@vishalmpj9485 2 жыл бұрын
thank u it's easy to understand
@mamo100
@mamo100 Жыл бұрын
So great explanaition that raisded a question for me: shouldn't we use a double pointer in "add_at_end" function? The head seems to be lockal in the function.
@monkman670
@monkman670 5 ай бұрын
you are amazing
@shivanshbhardwaj5841
@shivanshbhardwaj5841 4 жыл бұрын
amazing video sir!
@ShivarajNallagorla
@ShivarajNallagorla 8 ай бұрын
Please show the output of codes
@rahuldusad29
@rahuldusad29 3 жыл бұрын
sir please course complete pdha do sir bhut acha smjhya h apne
@sadiaafrin2623
@sadiaafrin2623 3 жыл бұрын
Your are the best
@roshangogu2670
@roshangogu2670 2 жыл бұрын
Helpful❤
@palashchandradas3277
@palashchandradas3277 2 жыл бұрын
Thank you so much.
@GAaron-uc9nm
@GAaron-uc9nm 4 ай бұрын
why can we use head->link->link = temp .....?
@mischieviousgirl
@mischieviousgirl 10 ай бұрын
5:21 code
@deepalikatara6531
@deepalikatara6531 4 жыл бұрын
Sir please provide the video lectures of design and analysis of algorithm for preparation of gate
@deepakpandey2100
@deepakpandey2100 4 жыл бұрын
Thank You 😊
@nikhilsachan8598
@nikhilsachan8598 4 жыл бұрын
Thanxx sr😊
@zichangprayingtothelord6087
@zichangprayingtothelord6087 3 жыл бұрын
At very end of addtoend function, don't we need to mention head=ptr?
@BREACH_X
@BREACH_X 3 жыл бұрын
Im getting this error please help me with this error: 'head' undeclared (first use in the function). How to solve this i use the exact code as shown on the video but it gives me error it does not work
@afreenpoly
@afreenpoly 3 жыл бұрын
Sir Are you uploading these code somewhere? I want the code
@tayyab.sheikh
@tayyab.sheikh 7 ай бұрын
Takeaway for me! You cannot learn data structures without making and understanding figures.
@Krishna-ek9jk
@Krishna-ek9jk 3 жыл бұрын
Your presentation and explanation good but what about remaining topics in neso app
@A2312GORREAARON
@A2312GORREAARON 4 ай бұрын
can we use head->link->link = temp , no need to traverse the list....?
@sudheerjalli4707
@sudheerjalli4707 4 жыл бұрын
When will you upload entire data structures nesoacademy plz upload soon????
@tradertrader2520
@tradertrader2520 3 жыл бұрын
4:50 I didn't get why not ptr !=null???
@akashpraveen9814
@akashpraveen9814 3 жыл бұрын
If we use ptr!= null, when ptr points to 3000, the condition executes and ptr->link part will get assigned to ptr( i.e) [ zero will be assigned to ptr].if this happens we can't able to find the last node where new node to be inserted..so instead we are check the node link part is zero or not
@AshokKumar-ix4nf
@AshokKumar-ix4nf 3 жыл бұрын
@@akashpraveen9814 but it have NULL value why it wouldn't assign NULL instead of 0 can u clear my doubt
@akashpraveen9814
@akashpraveen9814 3 жыл бұрын
@@AshokKumar-ix4nf sorry, i didn't get you
@vaibhavmourya65
@vaibhavmourya65 3 жыл бұрын
@@AshokKumar-ix4nf it's a same thing Null Or zero
@rodwynnejones
@rodwynnejones 4 жыл бұрын
Is there a reason why your doing "ptr = head" rather than just using the "head" (that you've actually passed to the function) in the "while" loop? I've done it both ways and both work.
@dimi5929
@dimi5929 2 жыл бұрын
if you use "head" you won't be able to access the first node as it would then point to a different node.
@sukshithshetty8349
@sukshithshetty8349 2 жыл бұрын
This code doesnt work, how should head be defined here?
@saiharshagurijala2066
@saiharshagurijala2066 3 жыл бұрын
this program won't execute correctly because there is no printf function. am i correct?
@JosephMokua-o5t
@JosephMokua-o5t 5 ай бұрын
It executes bro
@punky6320
@punky6320 4 жыл бұрын
First, thanks for your knowledge sir! For those who got error or something else, you may try this code: #include using namespace std; struct Node{ int data; struct Node *next; }; void add_at_end(Node *head, int data) { Node *ptr, *temp; ptr = head; temp = new Node; temp->data = data; temp->next = NULL; while(ptr->next != NULL) { ptr = ptr->next; } ptr->next = temp; } int main() { // Create a first node with data '45'. Node *head = new Node; head->data = 45; head->next = NULL; add_at_end(head, 98); // add second node. add_at_end(head, 3); // add third node. add_at_end(head, 67); // add forth node. Node *ptr = head; while(ptr != NULL) { cout
@NishantSingh-br6iu
@NishantSingh-br6iu 2 жыл бұрын
Thanks Brother 😊
@vaibhavborane6763
@vaibhavborane6763 2 жыл бұрын
I did not got the cout
@istutirajeev
@istutirajeev 3 жыл бұрын
Can you please tell that, are we supposed to call free( ) function for *ptr and *temp...within add_at_end( ) function?
@chandrikaiyer9141
@chandrikaiyer9141 4 жыл бұрын
Can't we do using two pointers only as we did in previous lectures
@nakulrajkr
@nakulrajkr Жыл бұрын
What if the list is empty when we try to insert a node? We have to check that, right?
@tulikagupta3998
@tulikagupta3998 3 жыл бұрын
hey this program is giving ivalid conversion from void* to *node i am not able to sort this out can you help
@patalamrithish6838
@patalamrithish6838 3 жыл бұрын
Typecast (struct Node*) malloc(sizeof(struct Node))
@siddharthkumar5600
@siddharthkumar5600 9 ай бұрын
that's grate
@HCJ-Technology
@HCJ-Technology 3 жыл бұрын
Sir am compiler not able to call function for add node
@alpha-vy9ej
@alpha-vy9ej 4 жыл бұрын
Sir please upload the video of graphs in dfs and bfs concept in code
@Cat_Sterling
@Cat_Sterling 4 жыл бұрын
What would be a good way to cover an edge case with an empty list here? What about this if statement before the while loop: if (ptr == NULL) ptr = temp;
@kuyaq8544
@kuyaq8544 3 жыл бұрын
yeah i was wondering the same thing
@pankajgopal7574
@pankajgopal7574 4 жыл бұрын
Sir this program showing error, will please solve the problem and send program again.
@ayeshaayesha232
@ayeshaayesha232 5 ай бұрын
Can anyone write the same code using switch case statement ,add at begin,end and specific position.i have tried but showing error.
@eyzhie9096
@eyzhie9096 2 жыл бұрын
In my case, why does my IDE say Application error when I run this code?
@dominiquefortin5345
@dominiquefortin5345 3 жыл бұрын
The use of a caboose is another way and it simplifies all the code. struct node *createList() {struct node *nd = malloc(sizeof(struct node)); nd->link = nd; return nd;}; void insertBefore(struct node *nd, int new_data) {struct node *new_nd = malloc(sizeof(struct node)); new_nd->link = nd->link; new_nd->data = nd->data; nd->link = new_link; nd->data = new_data;}; Now all the other functions get simplified : void add_beg(struct node *head, int new_data) {insertBefore(head, new_data);}; void add_at_end(struct node *head, int new_data) {struct node *nd = head; while (nd->link != nd) {nd = nd->link;}; insertBefore(nd, new_data);}; void add_at_position(struct node *head, int new_data, in pos) {struct node *nd = head; --pos; while (nd->link != nd && pos > 0) {nd = nd->link; --pos;}; insertBefore(nd, new_data);};
@suryatejapaili
@suryatejapaili 10 ай бұрын
Give me the notes for stacks and queue with program and algorithms
@shivam-qx2hd
@shivam-qx2hd 2 жыл бұрын
Here is the Executable Code: // how to add node at end #include #include struct node { int data; struct node *link; }; void add_at_end(struct node *head, int data) { struct node *ptr, *temp; ptr = head; temp = (struct node *)malloc(sizeof(struct node)); temp->data = 67; temp->link = NULL; while (ptr != NULL) { printf("%d ", ptr->data); ptr = ptr->link; } ptr = temp->link; printf("%d",temp->data); } int main() { struct node *head = malloc(sizeof(struct node)); head->data = 45; head->link = NULL; struct node *current = malloc(sizeof(struct node)); current->data = 98; current->link = NULL; head->link = current; current = (struct node *)malloc(sizeof(struct node)); current->data = 3; current->link = NULL; head->link->link = current; add_at_end(head, 67); return 0; }
@harijogi1621
@harijogi1621 Жыл бұрын
tq bro
@MdArman-f7n6j
@MdArman-f7n6j Жыл бұрын
thanks
@yogeshwaranraguraman9078
@yogeshwaranraguraman9078 5 ай бұрын
Bro, ptr = temp->link; ?? How? temp->link contains NULL right, You are assigning NULL instead of a New node address we have to assign ptr = temp; because temp contains the address of the new node and ptr contains the last link address as a NULL. so you have to assign ptr = temp; is correct. and temp->link contains NULL as already you have assigned. isn't it?
@PriyanshuRawat-db6sl
@PriyanshuRawat-db6sl 2 ай бұрын
@@yogeshwaranraguraman9078 ya it should be ptr->link=temp;
@22saithejasrireddy16
@22saithejasrireddy16 3 жыл бұрын
Sir where can I get this code ⁉️
@Nickname1234_
@Nickname1234_ 2 жыл бұрын
This node is visible only inside the function ....not in main then what's the use
@kaushaljha1384
@kaushaljha1384 3 жыл бұрын
Sir please complete the full code
@GopikaRaja-c7k
@GopikaRaja-c7k Жыл бұрын
What is wp =hd ??
@anyagoswami989
@anyagoswami989 2 жыл бұрын
Could you plzz provide cmplt code..
@CSstudent_1001
@CSstudent_1001 Жыл бұрын
The best 🤍🤍🤍
@istutirajeev
@istutirajeev 3 жыл бұрын
wow!
@harpreetvirk3308
@harpreetvirk3308 3 жыл бұрын
5 stars
@ajoydev8876
@ajoydev8876 2 жыл бұрын
but I can't even understand the difference between of them while( ptr! = NULL) Vs while(ptr -> link! = NULL) Please anyone can clarify?
@akshaya5037
@akshaya5037 2 жыл бұрын
ptr stores the address of the node. Like, I think to access elements of the node (data and next address) we need to use ptr->data and ptr->link. Like, if we want to stop when the next address is NULL, we can't be using ptr==NULL right? We want to stop when ptr->link == NULL. Like, ptr == NULL means, node's address is NULL, we can't get that way.... I hope you got it 😅
@austin2508
@austin2508 2 жыл бұрын
You can think of it this way. we are using ptr -> link = NULL here because: we want to check if we have the address of the next node, we are over-checking (ptr becomes NULL) if we use ptr only. In contrast, for the count and print functions, we use ptr != NULL, because: we are checking the entire node. If we do ptr -> link, we are missing one node. Because the last node is always the format of data, pointer. And this pointer is always NULL)
@karinakumari3671
@karinakumari3671 2 жыл бұрын
How to print a name using linked list
@aeroabrar_31
@aeroabrar_31 3 жыл бұрын
we can also write the code as ptr = head; while(1) { if(ptr->link == NULL) { ptr->link=temp; break; } ptr=ptr->link; } sir plz complete the play list as soon as possible.....🙏
@nehavashishth9354
@nehavashishth9354 4 жыл бұрын
but when i am printing it ,it is not showing anything.
@rithikvardhanreddy349
@rithikvardhanreddy349 4 жыл бұрын
Yeah even same problem to me i think its a source code if you know how to do keep comment ..
@abhishekmalviya4667
@abhishekmalviya4667 4 жыл бұрын
@@rithikvardhanreddy349 i think we have to try ptr->link != NULL instead of ptr != NULL then it should work.............
@roopaligarg792
@roopaligarg792 4 жыл бұрын
That might be because the list is initially empty. As soon as you add one node in the list this solution works, else this code needs to handle empty list scenario as well. @nesoacademy please correct me if i am wrong. Try adding this before while loop and it should work fine: if(head == NULL) { head = temp; return; }
@rithikvardhanreddy349
@rithikvardhanreddy349 4 жыл бұрын
@@roopaligarg792 yeah i think your right once i will try it
@tejagttggt
@tejagttggt 4 жыл бұрын
@@roopaligarg792 no it doesn't work because we r creating an another copy of head in the function, therefore we should use double pointers in the function parameter to reflect any changes to our main list.
@harmeetsingh7381
@harmeetsingh7381 2 жыл бұрын
👐
@sukshithshetty8349
@sukshithshetty8349 2 жыл бұрын
I am gettin a zero at the start of data at node? why
@sridevichowdary9763
@sridevichowdary9763 2 жыл бұрын
This code is not working 😔
@Vikaskarbail
@Vikaskarbail 3 жыл бұрын
Wow
@SUBHANKARDEY-ji6xs
@SUBHANKARDEY-ji6xs Жыл бұрын
run hi nhi kar raha
@vamsikrish7640
@vamsikrish7640 Жыл бұрын
waste of time all progrrams are incomplete
@JaisuryaPilla
@JaisuryaPilla Жыл бұрын
i got "Segmentation fault" ! what to do?? #include #include struct node { int data; struct node*link; }; void print_end(struct node*head,int data){ struct node*ptr,*temp; ptr=head; temp=malloc(sizeof(struct node)); temp->data= data; temp->link=NULL; while(ptr!=NULL) { printf("%d",ptr->data); ptr=ptr->link; } ptr->link=temp; } int main() { //node-1// struct node*head=malloc(sizeof(struct node*)); head->data=46; head->link=NULL; //node-2// struct node*current=malloc(sizeof(struct node*)); current->data=47; current->link=NULL; head->link=current; //node-3// current=malloc(sizeof(struct node*)); current->data=48; current->link=NULL; head->link->link=current; //node4// current=malloc(sizeof(struct node*)); current->data=55; current->link=NULL; head->link->link->link=current; print_end(head,49); return 0; }
Insertion at the End (Linked List vs. Array) - Part 1
7:35
Neso Academy
Рет қаралды 210 М.
Single Linked List (Inserting a Node at a Certain Position)
6:52
Neso Academy
Рет қаралды 345 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Introduction to Linked List
6:21
Neso Academy
Рет қаралды 1,7 МЛН
Single Linked List (Inserting a Node at the Beginning)
5:37
Neso Academy
Рет қаралды 525 М.
Single Linked List (Deleting the Node at a Particular Position)
9:43
Reverse a Single Linked List
11:57
Neso Academy
Рет қаралды 291 М.
I built a DeepSeek R1 powered VS Code extension…
7:02
Beyond Fireship
Рет қаралды 138 М.
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 389 М.
Linked List in C/C++ - Inserting a node at beginning
12:50
mycodeschool
Рет қаралды 1,1 МЛН
Deleting the Entire Single Linked List
6:06
Neso Academy
Рет қаралды 86 М.