Learn Introduction to Linked List concept Step By Step with examples.Types of Linked List.Array VS Linked List. Singly Linked list. Doubly Linked List.How to insert in Linked list.
What Is Linked List
A linked list is a linear data structure. There is nodes and link with each other. one node points to the next node and pointer called to other
Simple Linked List Class
- We use two are using two classes Node and List
- Declare both Node class for the nodes
- in this example data: double-type data in this example
- in this example next: a pointer to the next node in the list
class Node { public:
double data; // data
Node* next; // pointer to next
};
Types of Linked List
There are two basic types of linked list
- Singly Linked list
- Doubly linked list
you can find the detail in BOOk
Difference Array and Linked List
Array |
Linked List |
Fixed size | Dynamic size |
Insertions and Deletions are inefficient: Elements are usually shifted. | Insertions and Deletions are efficient: No shifting. |
Random access i.e., efficient indexing | No random access Not suitable for operations requiring accessing elements by index such as sorting |
No memory waste if the array is full or almost full; otherwise may result in much memory waste | Since memory is allocated dynamically(acc. to our need) there is no waste of memory |
Sequential access is faster [Reason: Elements in contiguous memory locations] | Sequential access is slow [Reason: Elements not in contiguous memory locations] |
<
Leave a Comment