Doubly Linked List – Implementation in C/C++

See complete series on data structures here:
http://www.youtube.com/playlist?list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P

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:
https://gist.github.com/mycodeschool/7429492

Lesson on Dynamic memory allocation:
https://www.youtube.com/watch?v=_8-ht2AKyH4

For practice problems and more, visit: http://www.mycodeschool.com

Like us on Facebook: https://www.facebook.com/MyCodeSchool

Follow us on twitter: https://twitter.com/mycodeschool

Comments

sergey freeman says:

at 13:35 shouldn’t head be 600 ?
Great videos by the way

Abhishek Jha says:

try to avoid global variables

manhapt vn says:

It’s the best “data structures” tutorial list I’ve seen in the planet !

Ashish Lakhani says:

Can we replace struct Node* GetNewNode(int x) function to void GetNewNode(int x) in 5:57

amateur beginner says:

if head is not global variable then this code is suitable:

struct Nodes* insertOnTail(struct Nodes *head1,int x){
struct Nodes *newnode=NewNode(x);
struct Nodes *head=head1;
if(head == NULL){
head=newnode;
return head;
}
while(head->next != NULL){
head=head->next;
}
newnode->prev=head;
head->next=newnode;
newnode->next=NULL;
return head1;
}

N. Prabanjan says:

Excellent Sir…I have cleared my doubt on insertAtHead…Pls upload videos for all position operations(middle,end,given position)

Yash Kothari says:

Also what do you mean by :

head -> prev = newNode;
newNode -> next = head;
head = newNode;

should we not write :
head = newNode;
newNode -> prev = head;

A U T. says:

what about the delete function? (the head/ tail/ nth location)
couldn’t find it in your source code
great tutoring btw :)

Kevin Caasi says:

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!

ARPIT J says:

thank you for making things simpler.

anand satija says:

sir ji u r great teacher

Aditya Aswal says:

From 8:16 onwards won’t it be 4 that will be stored in the address 600

Beatriz Rochelle says:

You do an amazing job at making stuff sound simple. Your help is much appreciated and inspiring. Thank you, thank you so much.

dao anh tuan Dao says:

your videos are helpful .I learned more good knowledge .

AMIT PANDEY says:

that was really amazing, .
BUT I AM QUITE WEAK AT THE BASICS, IS THERE ANY VIDEO OF YOURS WHICH WILL HELP ME CLEARING ALL MY BASICS FOR DATA STRUCTURES.

Yash Kothari says:

Is it necessary to explicitly make temp -> prev and temp -> next point to NULL when making a new node ?

Sheharyar Ahmad says:

it completely should be in c++, why c ,why malloc ?
for c++ seeker i dont think it is enough . :(
sorry

Daniela Bonvini says:

Thank you, finally getting to understand how DLL work

Keshav Sharma says:

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 … ?

shammah agwor says:

how many of you can successfully implement a link list and carry out some trivia operation on it after watching the series? in the scale of 0-100 rate your knowledge on linked list based on the series

Diogo Neves says:

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?

Dimebag Darrell says:

you are amazing

kishan tiwari says:

please update more on doubly link list

ROHIT BHAGAT says:

Watching this video lectures should be made a part of the College curriculum.These videos helped me a lot during preparations for Exams.

Alapan Das says:

can you please upload the same for circular,doubly circular linkists…

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours