How to insert a new node in a linked list in C++? (at the front, at the end, after a given node)

  Рет қаралды 152,746

CodeBeauty

CodeBeauty

Күн бұрын

Пікірлер: 353
@CodeBeauty
@CodeBeauty 3 жыл бұрын
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️ C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook 🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/ Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time! 💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10). Use it quickly, because it will be available for a limited time. #include using namespace std; class Node { public: int Value; Node* Next; }; void printList(Node* n) { while (n!=NULL) { cout Value Next; } } int main() { Node* head = new Node(); Node* second = new Node(); Node* third = new Node(); head->Value = 1; head->Next = second; second->Value = 2; second->Next = third; third->Value = 3; third->Next = NULL; printList(head); system("pause>0"); }
@alen91
@alen91 3 жыл бұрын
di si? pozz iz tz---kakvo je vrijeme u Mostaru?
@ashrafmugalli2179
@ashrafmugalli2179 3 жыл бұрын
Thanks for your videos you’re an amazing teacher. I’m paying for university but I learn better from your videos
@GenjaOrigins
@GenjaOrigins 3 жыл бұрын
Why not all the code at the end.
@aspabhi31
@aspabhi31 3 жыл бұрын
When we are inserting a node after specific node, why are we not passing address of previous node in the function insertAfter?
@dileepbokka5525
@dileepbokka5525 2 жыл бұрын
Share over all code
@mdmobarokrubel2635
@mdmobarokrubel2635 3 жыл бұрын
Please please please cover all the data structure and algorithm (DSA) topics. Loved all your C++ videos but if you cover DSA topics as well, hundreds and thousands will find help.
@eng6070
@eng6070 3 жыл бұрын
+10000000
@mariacunha8508
@mariacunha8508 2 жыл бұрын
pleeease!
@den15_zzz
@den15_zzz Жыл бұрын
Upppp!
@SavageScientist
@SavageScientist 3 жыл бұрын
i love how you pasted the source code right in the comment now thats accessibility
@fly4me2night
@fly4me2night 3 жыл бұрын
Lol Raw is the new thing
@aspabhi31
@aspabhi31 3 жыл бұрын
When we are inserting a node after specific node, why are we not passing address of previous node in the function insertAfter?
@SavageScientist
@SavageScientist 3 жыл бұрын
@@fly4me2night its Savage
@Aurora-bv1ys
@Aurora-bv1ys 2 ай бұрын
@@fly4me2night insane
@doublej118jc
@doublej118jc 3 жыл бұрын
I've watched a few of your videos and In one of them you mentioned your life-long dream is to be a teacher. You should definitely pursue that dream you're a VERY good teacher!
@sarwat3552
@sarwat3552 2 жыл бұрын
You can explain very thoroughly . Hands down this is by far the best linked list video I've ever come across KZbin. Please upload more such content, you have a great skill of expressing your ideas easily to people, best wishes
@beegameplay2.082
@beegameplay2.082 3 жыл бұрын
I liked your teaching style you are making your all viewers as a good coder. You clear all concepts easily speaking in english but others not and thats very helpful for all kinds of viewers. Love from Pakistan 🇵🇰❤️❤️
@sairanjanpanda736
@sairanjanpanda736 2 жыл бұрын
I was so confused about how to insert an node in the linked list but after watching this video I am not confused anymore. Your way of explanation is so good.
@Reem-du7sd
@Reem-du7sd 2 жыл бұрын
I never comment on KZbin videos but omg YOU ARE A LIFE SAVER! I've always found difficulty in coding, but thanks to your videos I am slowly gaining confidence. Forever grateful for all the knowledge you are sharing with us!❤
@minenhlenduduzonkabinde
@minenhlenduduzonkabinde 2 жыл бұрын
You are the best Code teacher I've come across Miss Saldina. Teachers like you are what we need. Taking us step by step through concepts with very detailed explanations and implementations. You are just outstanding. Truly impressive work.🥳. You are appreciated all the way from South Africa.
@CodeBeauty
@CodeBeauty 2 жыл бұрын
🥰❤️
@djordjeivkovic9787
@djordjeivkovic9787 3 жыл бұрын
I spent one month learning this in my class and here everything is explained in just 30min... GOOD JOB !!!
@supraocny
@supraocny 9 ай бұрын
Perfect explanation of inserting a node between two nodes. It took me what feels like forever to understand linked lists, but this helped a lot.
@rishus7938
@rishus7938 3 жыл бұрын
Please keep going. Most people give up making Yt videos. Very articulate explanations. I watched a few of your videos 7-8 months back. The delivery and clarity has improved a lot. And happy women's day. 😎
@exton69
@exton69 2 жыл бұрын
I don't write comments much but i am writing this to thank you for being my savior in my hard times such as my exams lol, you are lliterally the only coder on youtube who i have found to be so descriptive. Thank you for being on youtube .
@isaacmuwanga5707
@isaacmuwanga5707 3 жыл бұрын
I love your teaching style because it has made me to fall in love with C++ something I used to fear.
@luisalamo2658
@luisalamo2658 2 жыл бұрын
I Know that feel bro
@King-un8ui
@King-un8ui 3 жыл бұрын
I can't understand my professor at all, and your explanation is amazing. Thank you for this two linked list tutorials!
@CodeBeauty
@CodeBeauty 3 жыл бұрын
🤗🤗🧡
@aspabhi31
@aspabhi31 3 жыл бұрын
@@CodeBeauty When we are inserting a node after specific node, why are we not passing address of previous node in the function insertAfter?
@sieghart1931
@sieghart1931 3 жыл бұрын
@@aspabhi31 you will only need pointer to pointer when you want to change the value of the pointer, like in the insertAtTheFront(), you will make the *head to point to the newNode.
@programmingwithjackchew903
@programmingwithjackchew903 2 жыл бұрын
@@sieghart1931 isn't should be change the address of pointer?
@francois8441
@francois8441 2 жыл бұрын
This definitely helps me to understand the linked list. I searched a video on KZbin that is spoken in my mother language but all of them were much difficult than yours. In addition, they were too generalized from the beginning, but this point-by-point lecture makes me understand well.
@yunxinglu4020
@yunxinglu4020 3 жыл бұрын
Love your video! I spent the whole day yesterday and tried to understand what the linked list is. All other videos was confusing but now with your help and I totally get it! Thank you so much!!! Keep it up for the excellent work!
@ishaanpunetha
@ishaanpunetha 3 жыл бұрын
was so passionate about coding I'm just a young teenager....I also learnt c++ from an internet website for free....but as my exams approached my mom took my laptop for 2 months ....now I'm watching your that whole c++ video I was very sad about what happened but I'm back again! Thanks Hope you make more cources for different programming languages as well....
@maxdemendieta1426
@maxdemendieta1426 2 жыл бұрын
You’re a life saver, your videos are so clear and easy to understand, thank you so much for creating content like this
@lamprosgiannopoulos8489
@lamprosgiannopoulos8489 3 жыл бұрын
Just in time, i just finished the previous video and boom... another one. You're a speedrunner! 😜
@taayakin1108
@taayakin1108 2 жыл бұрын
I absolutely love these videos! Learning Data Structures and Algorithm implementations in C++ (as well as becoming more fluent with the language). Will be watching much more, thanks for the awesome content, you're a great teacher :D
@CodeBeauty
@CodeBeauty 2 жыл бұрын
Welcome, I'm glad 😃😃
@AnupamShaw
@AnupamShaw 3 жыл бұрын
I wish I had known about this channel during my high school. Data Structures were something that made me get frustrated and unlinked a lot of my brain cells. But it's never too late to learn. Thanks for this video. 👌😊
@anadhimitri4193
@anadhimitri4193 2 жыл бұрын
You are the best teacher ever. Period.
@CodeBeauty
@CodeBeauty 2 жыл бұрын
🥰🥰
@atohagan3588
@atohagan3588 3 жыл бұрын
best c++ instructor I have come across
@CodeBeauty
@CodeBeauty 3 жыл бұрын
☺️🥰🥰
@omeralsumeri5819
@omeralsumeri5819 3 жыл бұрын
Thank you so much, I love the way you teach and explain everything perfectly. I hope the best for you in all of your goals and pursuit of happiness.
@hicarodanrlley149
@hicarodanrlley149 3 жыл бұрын
I really appreciate your course about OOP. Thank you so much for that masterpiece work
@aspabhi31
@aspabhi31 3 жыл бұрын
When we are inserting a node after specific node, why are we not passing address of previous node in the function insertAfter?
@hicarodanrlley149
@hicarodanrlley149 3 жыл бұрын
@@aspabhi31 We just have the head node address, we have to loop through the linked list until the previous node. That's why we have O(N) for inserting after because we need to loop until the previous node and after that we insert our node
@luisalamo2658
@luisalamo2658 2 жыл бұрын
Your videos are a refresher to me, I learned these concepts with Pascal a few year ago for the university and I forgot it. Thanks!
@patriciacarvalhodemorais5769
@patriciacarvalhodemorais5769 Жыл бұрын
I need to thank ou so much!! I'm on university and have to make a test about data structures in c++, but I had no knowledge of c++ before, only python and a little bit of c, so I first watched your full course video and now I am watching this one, you are amazing!! Also I'm brazilian and your english is absolutely perfect!
@piiaall
@piiaall 3 жыл бұрын
Your explanation skill is great. Loved how you didn't start from a very complex way to implement a linked list✨️
@amanpratapsingh6056
@amanpratapsingh6056 3 жыл бұрын
Ma'am keep posting videos on Data Structures & Algorithms . Really love your way of teaching. Keep growing ma'am ❤❤❤❤❤
@BasitAli-uk6fj
@BasitAli-uk6fj 2 жыл бұрын
its very helpful video to every student whose want to learn DSA....i learn in just a 1 hours .....thanks allots from pakistan 👍....
@eduardogomez5345
@eduardogomez5345 2 жыл бұрын
Your explanations are the best, this is what I was looking for all this time
@mikaelasydney788
@mikaelasydney788 2 жыл бұрын
im so happy that you existed! you help me alot through my coding journey honestly you are better than my professor
@diabhattacharya3425
@diabhattacharya3425 Жыл бұрын
Great Work !The best teacher I've come across on yt so far!
@yashparasariya530
@yashparasariya530 3 жыл бұрын
This video made linked list far more easier to understand. Great work🔥
@dwivedys
@dwivedys 6 ай бұрын
These pointers -- are treacherous -- there’s no other way of saying this …thank you for your lovely explanation as always…
@CodeBeauty
@CodeBeauty 6 ай бұрын
You're welcome 🥰
@cashmoney12345
@cashmoney12345 Жыл бұрын
u explain things 10 times better tthan any professor or textbook has ever for me
@prateekshukla6056
@prateekshukla6056 3 жыл бұрын
I found your explanation easiest. I am very happy with your teaching style.
@mrtechsavvy8835
@mrtechsavvy8835 2 жыл бұрын
best explanation of linked lisgt ever seen on you tube
@muckiSG
@muckiSG 3 жыл бұрын
Just a suggestion especially on data structures. It would be much easier or most peaple to have some graphics. Linked lists, binary trees and so on are hard to explain with just your hands. :-) Thanks for your good work!
@Zita098765
@Zita098765 2 жыл бұрын
You're currently saving me for my head assignment (a family tree). Thank you!
@phantom_dorex_4573
@phantom_dorex_4573 4 ай бұрын
Thank you so much sister for the crystal clear explanation with each line of the code 🎉👍🙏
@abhaytomar6288
@abhaytomar6288 3 жыл бұрын
Amazing explanation, you have made this very simple and easy to understand. I was facing issue in understanding the insertion operation in linked list. Thanks for this.
@royalty-024
@royalty-024 Жыл бұрын
You have been so helpful. You explain in such a simple clear way and so straight to the point . I love your videos.❤♥💗💓
@ashikmujeeb9854
@ashikmujeeb9854 3 жыл бұрын
Hello ! Your lectures are very useful. Can u make more about Dsa like tree, graph etc. Your vedios are more understandable.
@CodeBeauty
@CodeBeauty 3 жыл бұрын
yess I will 🤗☺️🤞
@kannamsai9913
@kannamsai9913 3 жыл бұрын
Ma'am please cover all data structure and algorithm topics and also it would be very helpful if you give some standard practice questions on each topic, as homework and explain those practice questions in a new video.
@joebosah2727
@joebosah2727 3 жыл бұрын
This is a excellent presentation in simple understandable English. The topic was nailed. Thank you
@jonathanmascarenhas185
@jonathanmascarenhas185 2 жыл бұрын
You’re an amazing teacher. Thank you for your content I really appreciate it.
@muhammadsaif5744
@muhammadsaif5744 2 жыл бұрын
Most Underrated Channel ever
@shashimohansingh140
@shashimohansingh140 3 жыл бұрын
Thanks Saldina, You made it very easy for us to understand these topics. Once again big thanks.
@only_for_fun1234r
@only_for_fun1234r 2 жыл бұрын
Please take live lecture if possible so that we can ask questions in live chat 🙏🙏🙏 by the ways you are the best teachers for beginners 🥺
@PouyaZX
@PouyaZX Ай бұрын
Not Gonna Lie... You did a grate job explaining it
@bunman2353
@bunman2353 3 жыл бұрын
you just save my last assignment! Thank you!, you are such good teacher!
@raghavchawla1658
@raghavchawla1658 Жыл бұрын
best linked list video tutorial i came across
@CyberSpark23
@CyberSpark23 3 жыл бұрын
Hey Saldina! your videos have really helped me through uni the last 2 days, would you please cover double and circle LL? and defintley some sorting algorithims, keep up the good work!
@daniele9017
@daniele9017 3 жыл бұрын
Best teacher ever.
@shakshi9108
@shakshi9108 3 жыл бұрын
Your explanation is the simplest and best..thankyou for the good work
@ktubesk
@ktubesk 3 жыл бұрын
remarkable piece of Code especially the detailed explanation line by line , thank you So much.
@CodeBeauty
@CodeBeauty 3 жыл бұрын
🤗🤗🥰
@vincenzo6412
@vincenzo6412 3 жыл бұрын
Great video!! This helped me with a college class where my professor assumes everyone knows this and refuses to teach it loll. Thanks!
@iVuDang
@iVuDang Жыл бұрын
great explanation, thank you! love the outline in comments before you started coding in detail
@ChupoCro
@ChupoCro 2 жыл бұрын
Hehe, there is quite a lot going on with using pointer to pointer + sending a pointer by reference and Saldina of course knows it :-) Many asked why the address of pointer is used when inserting the node at the front. Here is another way of doing the same which might make it more understandable: Node* insertAtFront2(Node* n, int val) { Node* newNode = new Node; newNode->value = val; newNode->next = n; return newNode; // return pointer to a new head element } The node in front of the others is now inserted by: head = insertAtFront2(head, 201); Since the head (which is pointer to Node) variable has to be changed after inserting a new node in front of the others, the function returns a pointer to a new Node which is then used to update the head variable. Saldina used a function returning void and that's why she had to use another way of updating the head pointer outside of a function - which was to send the address of a pointer (a pointer to a pointer) as a parameter so she could update it by just dereferencing. In my example there isn't a way to update the head pointer by dereferencing the n variable because here n is sent by value and the function is working with the local copy of the head pointer. That's why I had to declare the function returning a pointer to Node and to assign that value after returning from the function.
@ikasugami
@ikasugami 3 жыл бұрын
I just discovered this channel - as a fellow female software engineer, it is so awesome to see a woman making coding videos!! ❤
@divanbasson5545
@divanbasson5545 2 жыл бұрын
Wow you really explain these concepts well.
@peterkaram7929
@peterkaram7929 3 жыл бұрын
continue doing all sort of videos your saving lifes
@Bess_Gates
@Bess_Gates Жыл бұрын
your teaching style i really really perfect
@IamSuperGirl22
@IamSuperGirl22 3 жыл бұрын
For the function insert, why you should use two ** after the Node? For example void InsertAtFront(Node**, int new_value)
@rameshbabu2085
@rameshbabu2085 Жыл бұрын
Ma'am please cover all data structure concepts. You are doing great ma'am. Love and support from India. Thank you❤
@CodeBeauty
@CodeBeauty Жыл бұрын
Thank you, I will. Love for India ❤️
@fayehill1225
@fayehill1225 2 жыл бұрын
Thanks a lot. One of the best tutorials I've watched!
@maurobaldini4582
@maurobaldini4582 2 жыл бұрын
Thanks! Really clear and easy to follow 😃
@saldanaswiz1291
@saldanaswiz1291 3 жыл бұрын
Beautiful explanation! Thank you so much!
@NaveenKumar-oz6wp
@NaveenKumar-oz6wp 4 ай бұрын
Superb explaination, thanks for much more clarification in a specific manner
@stephenelliott7071
@stephenelliott7071 2 жыл бұрын
That's a very clear and excellent video on linked lists.
@yohansenurga4044
@yohansenurga4044 3 жыл бұрын
Wow, Saldina thank you very much. I learned about the linked list in my c++ class course but I didn't understand much. Now I saw your video and it helped me a lot. And one more thing can you please make a video/videos about c++ classes using different(separate) files like header file - c++ file - main function file. Thank you in advance.
@yasubhaipk
@yasubhaipk Жыл бұрын
Explain in such way.. Oh my god... So niceeee.. thanks mam
@onurtannms3220
@onurtannms3220 2 жыл бұрын
Thanks a lot! One question: Why didn't you use pass-by-reference using pointers while implementing the last insertAfter function? You used it in the first two but not in the last one, that confused me a little bit. Other than that, I understood the topic very well. Your teaching is excellent.
@zanelezanzibar8333
@zanelezanzibar8333 23 күн бұрын
I think that is because the insertAfter function does not use head node, so you can easily get the address from the previous node since they are stored in the Next. With the first two functions the address of the head is not stored in any of the node so passing by reference make things easy. I don't know if this answers your question but I hope it make sense.
@jordiac5133
@jordiac5133 3 жыл бұрын
pls i love you thank you so much for your work❤️✨❤️✨❤️✨❤️✨❤️✨❤️❤️✨❤️✨❤️
@CodeBeauty
@CodeBeauty 3 жыл бұрын
❤️❤️🤗
@ArshiaBiswas
@ArshiaBiswas 2 жыл бұрын
beautiful explanation maam!I have gone through various linked list videos ...your video has no match honestly!so glad that I came across this ytchannel...and I must mention that u look beautiful as well maam
@michaelfgondwe
@michaelfgondwe 8 ай бұрын
The video have added more clarity on the coding experience
@PascalHFRIES
@PascalHFRIES 3 жыл бұрын
Bravo for this very educational tutorial!
@burntt999
@burntt999 3 жыл бұрын
lady. THANK you so much.. you helped me understand this and pass my tests. thank you tahnk you thank you thank you
@Kinsey_
@Kinsey_ 3 жыл бұрын
This video is super helpful and informative
@jasonzeng7643
@jasonzeng7643 2 жыл бұрын
Your video on LinkedList is super good. Not much tutorial video use C++ to teach LinkedList, and your video are the best. I have a question about why you passing a pointer to pointer in the insertFront and insertEnd function and passing pointer in the insertAfter function.
@daniellin2002
@daniellin2002 2 жыл бұрын
I like your videos because they help me to understand a new concept step by step. One quick question: I think the insertAtTheFront() and insertAtTheEnd(), the first parameter can be just *head, and no need to use **head?
@ehsanulhaqueraiyan8681
@ehsanulhaqueraiyan8681 2 жыл бұрын
your teaching technique is great!
@nasirhammi
@nasirhammi 6 ай бұрын
God bless you. Thank you so much for the very good explanation
@muadrico
@muadrico 3 жыл бұрын
Your code is more C-Style than modern C++. Maybe you can do video on how to refactor this code?
@adityamohan5293
@adityamohan5293 3 жыл бұрын
In the last part of the video ( insert after an element video) while we are assigning the "newNode -> next" to previous pointer(newNode -> next = previous -> next) why we are writing previous -> next instead of writing only previous like we did in the next line ( previous -> next = newNode)??? Just had this one doubt... Thankyou so much for this video no one made Linked list this much easy to understand. Waiting for Trees
@mukund.k28
@mukund.k28 3 жыл бұрын
In the first line, we were pointing our newNode's pointer to wherever our previous Node's pointer was pointing. In the second line, we point our previous node's pointer to newNode because doing "previous->next=newNode->next" would point it right back where it originally was, so the sequence doesn't really change other than the node after newNode has 2 pointers pointing to it. For a more clear visual explanation, go to a site called pythontutor, paste your C++ code.
@singhshiveshkumar
@singhshiveshkumar 2 жыл бұрын
Hello everyone, Hope you all are doing great! I am adding front node in this way. Please, let me know if you find anything wrong with this. void add_front(Node *head, int x) { // 1. New node created Node* zero = new Node; // 2. New node value assigned and contains the address of second node. zero->next = head->next; zero->value = head->value; // 3. head value is replace with x; head->value = x; // 4. now second node becomes zero. head->next = zero; }
@jeromeswizz4917
@jeromeswizz4917 Жыл бұрын
You have done an exemplary job!!! .God bless. Lifesaver.
@skill-f-mahi
@skill-f-mahi 2 жыл бұрын
You saved my day ma'am. Thank you.
@yashjoshi5439
@yashjoshi5439 2 жыл бұрын
Finally, I got the topic in my mind :). But I am getting little confused on using the pointer to pointer variable while declaring the function. I know about pointers well as I have watched your pointers playlist as well. But I am still in a bit of confusion.
@PureASM-ShellCoder
@PureASM-ShellCoder 3 жыл бұрын
Thanks a lot for explaining that so niceIy -I understood all of it ! 😊👍
@abugslife2461
@abugslife2461 2 жыл бұрын
Love this video!!! Thank you so much, very helpful!
@Asterics.
@Asterics. 8 ай бұрын
I had a hard times at this but you successfully guided me through 😉
@bhargavsolanki6386
@bhargavsolanki6386 3 жыл бұрын
You are lookin' gorgeous ma'am, your way of teaching is tremendous. Love from India😍
@saadiiii1680
@saadiiii1680 3 жыл бұрын
hate from bangladash
@abdiqadirabdi940
@abdiqadirabdi940 2 жыл бұрын
thank you a lot, it really help me for a full comprehension of the topic. Namaste
@ArslanBajwaOfficial
@ArslanBajwaOfficial 2 жыл бұрын
Mam how to delete and search in single linked list please let me know..
@sanderverhage5148
@sanderverhage5148 2 жыл бұрын
Small improvement of InsertAtTheEnd. You could use the next code to inserts the prepared node. While (*head!=NULL) head=&(*head->next); *head=NewNode;
@ms-hi2cc
@ms-hi2cc 2 жыл бұрын
one doubt why we are not using double pointer for insertAfter(Node* previous, int newValue)
@NguyenucNam_
@NguyenucNam_ 3 жыл бұрын
Love!!! So easy to understand it😍😍
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
SMART POINTERS in C++ (for beginners in 20 minutes)
24:32
CodeBeauty
Рет қаралды 104 М.
Understanding and implementing a Linked List in C and Java
18:15
Jacob Sorber
Рет қаралды 245 М.
Emulating a CPU in C++ (6502)
52:28
Dave Poo
Рет қаралды 1 МЛН
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 124 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 827 М.
SOME UNIQUE C++ CODE! // Pacman Clone Code Review
26:42
The Cherno
Рет қаралды 287 М.