Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doubly Linked list vs Multi-linked list in C/C++ [closed]

What is the difference between doubly linked list and multi linked list? It will be better explaining me with the help of a C/C++ program.

like image 492
Arun Avatar asked Dec 03 '25 08:12

Arun


1 Answers

Definition:

A multi linked list is a linked list where each node may contain pointers to more than one nodes of the linked list.

Doubly linked lists are a special case of Multi-linked lists. It is special in two ways:

  1. Each node has just 2 pointers.

  2. The pointers are exact inverses of each other.

Example:

A multi linked list:

enter image description here

A doubly linked list:

enter image description here

Representation:

Multi linked list:

typedef struct node
{
    int data;
    vector<struct node *> pointers;
}Node;

Doubly linked list:

typedef struct node
{
    int data;
    struct node* prev;
    struct node* next;
}Node;
like image 98
HelloWorld123456789 Avatar answered Dec 04 '25 21:12

HelloWorld123456789



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!