Re: What is a linked list?
Linked list is a type of datastructure that collect either different type of data or same type of data. These data are basically stored in node. Usually node have non primitive data that are stored in to two parts. One part have data and other part have address of next node.
Re: What is a linked list?
Linked list is a type of datastructure made up of nodes that collect various data. Each node have two parts one is Information part and other is linked part.
1.Information part=This part contain value of data elements.
2.linked part=This part contains address of the next node or adjacent node.
In Linked list we stored information linear format.
Re: What is a linked list?
A linked list is collection of data in linear format. It consist of nodes. All nodes are linearly connected. The linear format is supported by pointer. You can find linked list in either doubly or liner or circular format.
Re: What is a linked list?
Here I just given you program to understand linked list.
Code:
Basic linked list example
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Linkedlist {
char *str1;
struct Linkedlist *next1;
};
int main(void) {
char line[1024];
struct Linkedlist *h = NULL;
struct Linkedlist *n = NULL;
while(fgets(line, 1024, stdin) != NULL) {
n = (struct Linkedlist *)malloc(sizeof(struct Linkedlist));
n->next1 = h;
h = n;
n->str1 = strdup(line);
}
while(h != NULL) {
printf("%s\n", h->str1);
h = h->next1;
}
return 0;
}
Re: What is a linked list?
Since most people tend to always give absolute definitions I'll try to explain it in layman's terms.
a linked list is a list of items that in some way relate to each other to create a kind of data structure that can be read through and manipulated easier. like links of a chain.
example
you can have 2 linked lists that work with each other.
1 can be prices of seats of and airline
and the other can be a list of passengers for the airline and the seat they reserved.