Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between the data structure List and Graph?

I know that singly linked lists are made of nodes where each node has a pointer to the next node (or null to end the list), but graphs also have nodes with data and pointers to the next.

So what's the essential difference between the data structure Linked List and Graph? And how about the List-based search and Graph-based search?

like image 328
Anatoly Avatar asked Apr 18 '15 12:04

Anatoly


1 Answers

It is not true, linked list also have data in it's nodes!(why do you want to have a list of nodes without any information?), In fact from mathematical view a linked list is some sort of graph.

The main difference between graph in general and linked list is that a node in linked list could at most have two pointers(one to its next and one to its previous node) but a node in graph could have more than two pointers.

like image 58
Lrrr Avatar answered Sep 30 '22 00:09

Lrrr