c++ - How to implement a doubly linked list? -
We learned to implement the linked list alone in the classroom. And like our professor, we have mentioned making a double list, but apparently it is so easy that he did not really understand how to do it completely. I'm really good at working with a list of alone links, but can someone tell me how to make a double link list?
If you already have a sound definition of the link went list alone, a double link list it's easy.
Before you probably do something like
struct link {struct link * next; // An indicator for node that comes in the next int value; } It will need to be changed to
straight link {struct link * next}; // An indicator for the node that comes with the next structure link * prev; // a pointer in the node that comes before the int value; } Now you can basically reverse your tasks using the previous instead of the next place while changing the list.
Keep in mind that by adding or removing your 'keep a book to keep things right on the right things', keep in mind that.
I always tell the students that while writing the work, attracting every step of linking and removing from a linked list is attracted. And always to make sure that unless it is removed, you can refer to everything in your drawing through any indicator.
Comments
Post a Comment