Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
April 3rd, 2013, 11:17 PM
 miz6565
Registered User

Join Date: Mar 2013
Posts: 96
Time spent in forums: 22 h 2 m 11 sec
Reputation Power: 0
A tutorial for double linked lists?

Hi - I decided to learn a better perspective of binary trees later on in the weekend. But during the week I want to try to attempt doubly linked lists. Shouldn't be so hard, right? I understand linked lists fine so I don't think double linked lists should be no jiffy.

I'm already thinking the structure should be this:
Code:
```typedef struct doubly {
int val;
struct doubly *next;
struct doubly *previous;
} doubly;```

But, like my brain always works, I'm not sure how I can put this in use. So I'm asking, can someone send me an accurate link to a good tutorial? I tried looking it up on google but all I found was examples and no explanations to those examples.

That'll be great. Like I said, this shouldn't be any more complex to understand. So just getting a tutorial on the webs would be great. thanks

#2
April 4th, 2013, 01:32 PM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,116
Time spent in forums: 1 Month 3 Weeks 2 Days 3 h 2 m 43 sec
Reputation Power: 455
This author feels the same way you do and did something about it.

I draw linked lists on paper. Then given some access node I decide if I'll work to the "next" or "previous" side, and I circle or mark the pointers I need to change for an insertion or deletion, figure out the order these need to happen (including decisions about malloc and free). Then write the code to match. So for a doubly linked list there are usually 4 pointers you need to change. As always you need to also consider the end cases. What happens with no nodes, one node, two nodes, three nodes---after that I'm pretty sure you're all set.
__________________
[code]Code tags[/code] are essential for python code!

 Viewing: Dev Shed Forums > Programming Languages > C Programming > A tutorial for double linked lists?