Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Write a program to implement doubly linked list. Explain how, it is different from circular linked list?

0
Posted

Write a program to implement doubly linked list. Explain how, it is different from circular linked list?

0

Check out the simple one struct node { node(int data_p) { data=data_p; next=0; } int data; node *next; }; node *head=0; void addNode(int data) { node *curNode=head; if(head==0) { head=new node(data); return; } while(curNode->next) curNode=curNode->next; curNode->next=new node(data); } int main() { addNode(7); addNode(1); addNode(40); node *curNode=head; while(node) { cout << node->data; node=node->next; } } The difference is how many pointers each node has, and what they are pointing to. A linked list is comprised of “Nodes” each node contains data as well as 1 or more pointers. A singly linked list has one pointer per node, and a doubly linked list has 2 pointers per node. Some programs use several pointers per node. The purpose of these pointers is to hold the list together. In a singly linked list, you can view a node and can then move on to the next node that it is pointing to until you’ve passed through them all. A doubly-linked list would have a pointer to the next node as well a

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123