Doubly Linked List - Implementation in C/C++

  Рет қаралды 583,463

mycodeschool

mycodeschool

Күн бұрын

See complete series on data structures here:
• Data structures
In this lesson, we have implemented doubly linked list data structure in C. We have written basic operations for traversal and insertion.
See source code here:
gist.github.com/mycodeschool/...
Lesson on Dynamic memory allocation:
• Pointers and dynamic m...
For practice problems and more, visit: www.mycodeschool.com
Like us on Facebook: / mycodeschool
Follow us on twitter: / mycodeschool

Пікірлер: 280
@kunal1035
@kunal1035 3 жыл бұрын
8 years passed by and this channel is still helping thousands!!
@knanzeynalov7133
@knanzeynalov7133 Жыл бұрын
exactly, even in 2023.
@DhivyaGnanasekar
@DhivyaGnanasekar 9 ай бұрын
Yes
@sahelisohanitwins7492
@sahelisohanitwins7492 5 ай бұрын
2024 also
@Hello_world807
@Hello_world807 4 ай бұрын
10 years passed by and this channel is still helping thousands!!
@nguaial8490
@nguaial8490 8 жыл бұрын
I just want to mention that I really appreciate you repeating the important concept over and over again. I don't know about the others, but I really have hard time grasping the memory structure concept inside a computer since I haven't seen one. The only way I get it is when I look and listen the subject repetitiously.
@kevincaasi926
@kevincaasi926 7 жыл бұрын
This is beautiful. Thank you for taking your time and effort in explaining how to implement doubly linked lists as well as their actions on the different memory locations. You possess great pronunciation, clarity, knowledge, and appropriate talking speed. Thank you!
@pranavofindia
@pranavofindia 5 жыл бұрын
lets watch the complete ads without skipping and appreciate this man.
@navkaransingh3948
@navkaransingh3948 5 жыл бұрын
@ how ?
5 жыл бұрын
He died in a hit and run. Someone hit him with his/her car and ran and drove off.
@lasyagajavelli594
@lasyagajavelli594 5 жыл бұрын
really..?
@standardgu3773
@standardgu3773 5 жыл бұрын
@@lasyagajavelli594 I want to know the truth....
@lasyagajavelli594
@lasyagajavelli594 5 жыл бұрын
@@standardgu3773 I don't knw either...wherever he is he has to be happy
@kanishkjain2767
@kanishkjain2767 5 жыл бұрын
wow sir finally i understand why we are using dynamic memory allocation instead of normal allocation i know you cant read any of our comments but still i want to say that u will always be the best teacher not only for me but for most of the online community who are still watching and learning from your videos
@mymanhapt
@mymanhapt 8 жыл бұрын
It's the best "data structures" tutorial list I've seen in the planet !
@zeeshanayub9706
@zeeshanayub9706 6 жыл бұрын
Sir, I can't even express how helpful your tutorials are to me. Thank you so much for making them!!
@antor.morsalin
@antor.morsalin 11 ай бұрын
There is an easier way to print a list in reverse. We can always store the address of the last Node in the variable Node* tail. Tail will change depending on which Node is at the last position each time we add a New node in the list. We can start at the Tails and using the previous address we can print the list in reverse order, This way we won't have to iterate the entire list before printing it in reverse. I also want to say this is a great video series. The clarity I got on this topic just after watching it once is insane.
@justdanaus
@justdanaus 4 жыл бұрын
I don't know why my professor can't not explain this easy as you do! I really hate pointer until I found your great video. You got new subscriber!
@monicaslv323
@monicaslv323 8 жыл бұрын
Thank you for every codeline of yours.
@scotfsh5014
@scotfsh5014 Жыл бұрын
Thank you so much humblefool, you make the world a better place.
@Facttoknowabout
@Facttoknowabout 3 ай бұрын
10 years passed but this channel is helping students now also .
@TheHyperActiveRedditBot
@TheHyperActiveRedditBot Жыл бұрын
Your way of communicating an idea is near perfect (unlike most other coding youtube channels). Keep up the good work.
@knanzeynalov7133
@knanzeynalov7133 Жыл бұрын
@@mahedihassanshawon4821 are you serious????/
@hassan4834
@hassan4834 8 жыл бұрын
You have done a great Job ! You really made things easier to understand.. Lectures like this are very hard to find on internet hats off :)
@bhavanababua959
@bhavanababua959 3 жыл бұрын
I cleared my technical interview after watching these video. Thanks for uploading these clear and precisely explained videos.
@dheerajdhall8482
@dheerajdhall8482 7 жыл бұрын
Thank you for taking out time and making these videos. I really like the way you explain these concepts. Cheers!!
@raduchirilov4800
@raduchirilov4800 4 жыл бұрын
This is the very definition of a "clear code" Thank you so much!
@maliksaraanasim5404
@maliksaraanasim5404 4 жыл бұрын
Yaar bhai tum saviour ho,I can not thank you enough .Seriously.
@firkyunbanaya
@firkyunbanaya 7 жыл бұрын
Watching this video lectures should be made a part of the College curriculum.These videos helped me a lot during preparations for Exams.
@pcpardon
@pcpardon 3 жыл бұрын
Impeccable explanation!!! Cleared all the doubts what I had. I have no words to say thanks..
@anusrees3991
@anusrees3991 6 жыл бұрын
this is the frst tutorial in which i see things explained via code, graphical representation and memory allocation process
@renelhomere5243
@renelhomere5243 8 жыл бұрын
Thank you so much, you've help me get through the portion of class. 👍🏾👍🏾
@danielabonvini2936
@danielabonvini2936 7 жыл бұрын
Thank you, finally getting to understand how DLL work
@meghamalviya8495
@meghamalviya8495 5 жыл бұрын
BEST Tutorials of DS...excellent explanation...supreme clarity and knowledge
@TheFlexath
@TheFlexath 4 ай бұрын
the best data structures playlist ever!
@user-re8bl1nu8y
@user-re8bl1nu8y Жыл бұрын
this is the best DS video i have ever seen
@thestarinthesky_
@thestarinthesky_ 4 жыл бұрын
@3:13 BLOWS MY MIND! Impressive! Thank you.
@AlphaZubair
@AlphaZubair 4 ай бұрын
10 years passed by and these explaination of concepts are Just like a WoW...
@ucthuanphung4530
@ucthuanphung4530 6 жыл бұрын
Videos are extremely clear and useful. Thanks a lot.
@shobhitrealm
@shobhitrealm 5 жыл бұрын
RIP man, even though you are no more your videos are still helping us all.
@KeshavUjoodha
@KeshavUjoodha 4 жыл бұрын
He isn't dead. His name is Animesh Nayan . His friend Harsha Suryanarayana is the co-founder to this channel and he is no more. He died in a car accident 15th June 2014. Animesh Nayan is a Software Engineer at Google. "Harsha was the best coder India has ever produced. He was working in a start-up (that he co-founded with Animesh Nayan) MyCodeSchool. He was alumni of Indian Institute of Information Technology, Allahabad. We lost him in a hit and run accident on the night of 15th June 2014." [Source: fossiiita.github.io/humblefoolcup/humblefool/humblefool.html]
@gamereplayhq
@gamereplayhq 8 жыл бұрын
is this a good approach , i just included a constructor which set next and prev to NULL , so that we dont need to worry about setting up next and prev while inserting a new node ? struct node { node *next; node *prev; int data; node() { next=NULL; prev=NULL; } } *start=NULL,*temp,*end=NULL; void insert_beg(int x) { temp = new node; if(temp==NULL) exit(0); temp->data =x ; temp->next=start; if(start!=NULL) start->prev = temp; start=temp; if(end==NULL) end=start; //initially } is this a good approach ? since now we need not worry about next and prev being NULL , since they would by default be pointing to NULL ... ?
@lucafrazz6199
@lucafrazz6199 8 жыл бұрын
Very awesome! I don't speak english very well but i have understood all... this is a very nice tutorial.
@aryannijhawan8448
@aryannijhawan8448 3 жыл бұрын
u said u were gonna talk about circularly linked list . This is really an amazing playlist I wish this was more comprehensive. Thanksss :)))
@asmereg
@asmereg 3 жыл бұрын
Such a great teacher! Please come back
@arukoul6364
@arukoul6364 6 жыл бұрын
Thank you so much, your videos are really very nice for learning Data Structures. Thank you, Sir for this beautiful learning gift.
@rabinrai5838
@rabinrai5838 7 жыл бұрын
sir where is the video for circular linked list????? and thanks for ur videos helping me a lot
@arpitj795
@arpitj795 7 жыл бұрын
thank you for making things simpler.
@mohitsrvv
@mohitsrvv 2 жыл бұрын
many years but still watching thanks
@abhirupbasak5035
@abhirupbasak5035 3 жыл бұрын
you guy just amazing ..even my teacher can't explain like this
@Maurin4000
@Maurin4000 9 жыл бұрын
best explanation so far, thx a lot
@manansatra
@manansatra 6 жыл бұрын
Hi, you said that the newNode in GetNewNode is local to GetNewNode but previously you mentioned that the output or the node we get from the malloc function or new Node is global and so the newNode variable were we store the result of malloc should also be global. I am confused and the statement seems contradictory to me. Could you please help me with my confusion? Thanks.
@roopanrodin7924
@roopanrodin7924 5 жыл бұрын
Thank so much for the lesson. It was very useful, thank you a lot
@oscarwang7920
@oscarwang7920 5 жыл бұрын
wait , so by the way you insert node, after the second and third insertions, the order will actually be " head (which is the third insert node) -> node (from the second insertion) -> node( from the first insertion) " Therefore, you are always making the new insert node as the first one in the list but not the last one ? Can anyone tell me what is the standard way or most common way to order the double link list when it comes to insertion ?
@kuonkhailechdawech2309
@kuonkhailechdawech2309 Жыл бұрын
You're legend brother 🙏
@poojagoyal869
@poojagoyal869 7 жыл бұрын
One of the best tutorial...thank you sir...
@DiogoNeves
@DiogoNeves 8 жыл бұрын
This is brilliant! Thanks! :) You don't talk about deallocating the nodes after we're done with the list. Shouldn't that be done explicitly since we allocated them in the heap?
@Mhmoudko
@Mhmoudko 9 жыл бұрын
Thank you man , you're a life saver ...
@sreekumarmenon
@sreekumarmenon 10 жыл бұрын
isn't it more efficient to have a tail pointer (similar to head pointer) to traverse backwards?
@mycodeschool
@mycodeschool 10 жыл бұрын
We may or may not keep a tail pointer. Its good to keep a tail pointer, depends upon the use case. When we implement queue using doubly linked list, we keep a tail pointer. But in general, if we would have two links - forward and backward, that's what we would call a doubly linked list.
@findoc9282
@findoc9282 3 жыл бұрын
Bro thank you so much and I wish u had good life up there
@CODINC
@CODINC 6 жыл бұрын
Absolutely Amazing man!!!
@Rizzan8
@Rizzan8 7 жыл бұрын
Wouldn't the use of malloc and not using free() cause a memory leak?
@Christine-ne3dw
@Christine-ne3dw 4 жыл бұрын
Thanks, I appreciated this a lot.
@wannabe.explorer
@wannabe.explorer 8 жыл бұрын
cleared my concept..thanks sir!!
@ricardohincapie1537
@ricardohincapie1537 4 жыл бұрын
Thank you very much for this video. It is really understandable!
@ChauTran-mh5qo
@ChauTran-mh5qo 5 жыл бұрын
Hi bro, When you implement the function "InsertAtHead(int x)", why don't we use the following implementation //********* head -> prev = newNode -> next; newNode -> next = head -> prev; head = newNode; //********* I know that is incorrect, but can you help to clarify my misunderstanding. Thanks and Regards,
@Nino-bd7bp
@Nino-bd7bp 7 жыл бұрын
OMG thank you very much!!! This really helped me :)
@TheDigitalPedia
@TheDigitalPedia 8 жыл бұрын
Great stuff you guys are producing i must say. Have you guys posted videos on priority queues+heaps and Graphs?? If yes so any link you can provide?
@RatIceCream
@RatIceCream 2 жыл бұрын
Thanks for uploading!
@ainmiky4620
@ainmiky4620 4 жыл бұрын
Hi i want to create a singly linked list in C with 4 nodes. The first two nodes should contain strings and the last 2 nodes should contain numbers (int). I know how to create a linked list with integers as data types, but I don't know how to input strings into the nodes. Can you help me?
@mattm32
@mattm32 3 жыл бұрын
Thanks you for this wonderful video, how do we modify the code to use it us generic list, i try to use void pointer but i got an error on type casting it bc the data types can different in the same list? Thanks again!!!
@harshitsoora1313
@harshitsoora1313 6 жыл бұрын
awewewewesome bro ,you have superb teaching experience ,aise hi machatte raha
@RajahChandrasekhar
@RajahChandrasekhar 5 жыл бұрын
Best tutorial ever!!!
@095_shaniabalkhi9
@095_shaniabalkhi9 2 жыл бұрын
Great explanation!
@akashdeep504
@akashdeep504 9 жыл бұрын
please upload some lectures on dynamic programming
@vijaymalawadkar6830
@vijaymalawadkar6830 6 жыл бұрын
Thank you for easy explanation of linked list
@yichizhang795
@yichizhang795 9 жыл бұрын
Good work sir, Thanks!
@pulkit0581
@pulkit0581 8 жыл бұрын
thanks alot. This is very helpful. Please suggest how should i proceed for preparing competitive programming after going through all the data structure series and others available on mycodeschool
@sagarvyas304
@sagarvyas304 9 жыл бұрын
in the 8.52 mins of the video we see how to add a new node to the non empty list. but we write 1.head->prev=newnode; 2.newnode->next=head; 3.head=newnode; so my question is can we write newnode->next=NULL; instead of the 2nd statement?
@MOHDNAVEED1
@MOHDNAVEED1 10 жыл бұрын
awesome compilation
@machinelearning3518
@machinelearning3518 2 жыл бұрын
i'm grateful for ur video
@muathkifaya9582
@muathkifaya9582 8 жыл бұрын
hallo , if we want insert data at nth position in doubly linked list , How do that ?
@mashable8759
@mashable8759 7 жыл бұрын
All the tutorials are the best and really helpful :D MAY ALLAH GUIDE YOU
@shobhitrealm
@shobhitrealm 5 жыл бұрын
He is no more. He died on 15th June 2014.
@muktamalakar5771
@muktamalakar5771 5 жыл бұрын
Fuck off dude, if you want to believe in 7th century bullshit, don't use technology and watch these videos.
@yogabrindha5640
@yogabrindha5640 3 жыл бұрын
Clean explaination
@lilianawong4819
@lilianawong4819 4 жыл бұрын
When the new node was created with the address 600 was it suppose to be | 0 | 4 | 0| ?
@daoanhtuandao8106
@daoanhtuandao8106 7 жыл бұрын
your videos are helpful .I learned more good knowledge .
@antoniomellobabo1229
@antoniomellobabo1229 3 жыл бұрын
Thx helped a lot!
@antragupta1001
@antragupta1001 6 жыл бұрын
sir always u say thanks for watching ..today I m saying thanks for making ......I can't tell u how relieve I m feeling after watching this ..... cz tomorrow is my exam ... 😍😍😍
@koulicksadhu7679
@koulicksadhu7679 4 жыл бұрын
Sir is no more
@drewpatton4275
@drewpatton4275 4 жыл бұрын
You are a saint.
@shivanshbhardwaj5841
@shivanshbhardwaj5841 3 жыл бұрын
Great video!!!!!!!!!!!!!!!!
@malazalzarrad6064
@malazalzarrad6064 3 жыл бұрын
you are the king
@w4h175
@w4h175 3 жыл бұрын
hats off sir ji..
@nehagurav312
@nehagurav312 5 жыл бұрын
very helpful! thank you!
@usama57926
@usama57926 6 жыл бұрын
this tutorial is amazing
@mirzaavez6284
@mirzaavez6284 9 жыл бұрын
Thanks sir for explaining this topic
@Credi44
@Credi44 4 жыл бұрын
can someone explain whats the difference between using while(temp !=null) and while(temp->next!=null)? they seem to give the same output either way
@hell-bringer
@hell-bringer 4 жыл бұрын
what is head at 7:13 ? Is it of type struct node ?
@prakashkhare2824
@prakashkhare2824 4 жыл бұрын
sir i implement function for the insertion at nth position,in forward function it print but in the case of reverse print it doesn't print the element of nth insertion InsertAtN(int x,int n) { Node* temp = GetNewNode(x); Node*temp1 = head; for(int i = 0; inext; } temp->next = temp1->next; temp->prev = temp1; temp1->next = temp; Node* temp2 = temp->next; temp2->prev = temp1; }
@stevejerry808
@stevejerry808 4 жыл бұрын
really solid thank you
@anandsatija6172
@anandsatija6172 7 жыл бұрын
guru dronacharya of data structure :)
@suhailaijaz7085
@suhailaijaz7085 5 жыл бұрын
anand satija 😂😂😂
@MrBomer213
@MrBomer213 4 жыл бұрын
hello thank you foe the video its awesome! i have a question and its killing me, at 8:32 you're inserting InsertAtHead(2) and InsertAtHead(4) but in your drawing you have '2' in address 400 and '2' in address in 600 did you mean to put 4 ?? or are we replicating the Head with the val 2?
@ishanpand3y
@ishanpand3y 4 жыл бұрын
he mistakenly wrote 2 instead of 4
@r3fl3xplays36
@r3fl3xplays36 6 жыл бұрын
could you please make 1 video regarding efficient doubly linked list (using XOR operator). it isn't available on youtube.
@koulicksadhu7679
@koulicksadhu7679 4 жыл бұрын
He is no more bro
@ankittarway6018
@ankittarway6018 6 жыл бұрын
very helpful !!! thanks a lot
@bleep4930
@bleep4930 7 жыл бұрын
awesome videos broh..thanx a lot..how do u writ em ? lik wat software do u use..or what device ?
@bilalqadri5312
@bilalqadri5312 2 жыл бұрын
very helpful tutorial ❤❤❤❤❤
@thesimulatedcreator6187
@thesimulatedcreator6187 3 жыл бұрын
Is it necessary to initialize head as NULL in the main? Can't we just initialize it as NULL just when we declare it?
@MrFalcon58199
@MrFalcon58199 8 жыл бұрын
can someone tell me where the main function in memory is? when I read my college books on one page it says it's in stack, on the other page it says it's in code segment
@Drwildy
@Drwildy 4 жыл бұрын
3 Years late, It is on the stack.
@kalyankumard2243
@kalyankumard2243 3 жыл бұрын
Here memory is not deallocated from the heap memory, it does memory leak, how to avoid the memory leak in the linked list (single and double linked list). when do i deallocate the memory from heap area.
@46_wrtyui
@46_wrtyui 8 жыл бұрын
Very awesome class. But please reduce the time on the difference among the memory sections since it already introduced several times in previous lessons.
@yashkothari7540
@yashkothari7540 7 жыл бұрын
Also what do you mean by : head -> prev = newNode; newNode -> next = head; head = newNode; should we not write : head = newNode; newNode -> prev = head;
@tomasz-rozanski
@tomasz-rozanski 7 жыл бұрын
If you insert newNode at head, newNode->prev will always point to NULL because it's now first element in the list (a new head). The old head is becoming the second element of the list, that's why newNode->next must points to it and head->prev points back to newNode. In your example head will be equal to newNode, newNode->prev will point back to newNode itself and newNode->next is already NULL. This way every time you're inserting node at head you're really throwing away the old head node so the list will always have one element - the last one you have inserted.
@siddharthmagadum16
@siddharthmagadum16 4 жыл бұрын
Thank you very much... 👍
Data structures: Introduction to stack
8:26
mycodeschool
Рет қаралды 603 М.
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 11 МЛН
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 26 МЛН
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 38 МЛН
Useful gadget for styling hair 🤩💖 #gadgets #hairstyle
00:20
FLIP FLOP Hacks
Рет қаралды 10 МЛН
Linked List in C/C++ - Insert a node at nth position
15:15
mycodeschool
Рет қаралды 728 М.
Linked List - Implementation in C/C++
13:58
mycodeschool
Рет қаралды 1,6 МЛН
2.4 Linked List Implementation in C/C++ | Creation and Display | DSA Tutorials
29:01
Jenny's Lectures CS IT
Рет қаралды 1,7 МЛН
Pointers and dynamic memory - stack vs heap
17:26
mycodeschool
Рет қаралды 1,4 МЛН
Understanding and implementing a Linked List in C and Java
18:15
Jacob Sorber
Рет қаралды 234 М.
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 275 М.
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2,1 МЛН
Introduction to linked list
17:13
mycodeschool
Рет қаралды 1,6 МЛН
why do void* pointers even exist?
8:17
Low Level Learning
Рет қаралды 344 М.
STRUCTS in C++ explained 🏗️
5:01
Bro Code
Рет қаралды 9 М.
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 11 МЛН