Dynamic Memory Allocation:
Dynamic memory allocation means to access memory randomly. In arrays we got series of memory locations. But the drawback of the array is that it has a fixed size. And it will take that fixed memory even if you don’t use all the locations. From here the concept of dynamic memory arises. So we get different locations in memory and than link them. We can achieve this by Linked List.
Linked list is a dynamic data structure. In linked list we have a structure called node. The structure has 2 parts one part is called data and other is called link. Link is used to tie new node. A linked list must have a START pointing to first node. Think of link list as a train with START as an engine of the train. So here is a linked list.
So as you can see in the figure we have a structure of node. And last node has a null link in it indicating end of the list.
Here is a code how to create node in c++
in this structure we have created a node with one data member and one link.
Here is a full code of linked list its insertion and display.
Note: please make sure to copy the start of list while traversing the linked list if you perform operation on start and update it, by doing this you will lost your start of list.
For understanding structures in c click on link
For understanding Pointers in c click on link
For more queries comment below thanks.