Posts

Showing posts with the label introduction to linked list

Introduction to Linked List| Data Structure with Python

Image
   Linked List is a linear data structure. Unlike arrays, linked list elements are not stored at a contiguous location. The element are linked using pointers. Why Linked list is used:- Arrays can be used to store linear data of similar types, but arrays have the following limitations. Array's size is fixed. So we must know the highest limit of the array in advance. So we must declare the size of the array first and elements there after.  Inserting a new element is very expensive because the room has to be be created for the new elements and shift the existing elements. Ex :- Suppose we have arrays in sorted order   i.e. [1,2,3,4,6,7]  and we have to insert new element   i.e. [5]   in the array. So in order to maintain elements in sorted order, we have to place that element after suitable element. In this situation we have to shift the element   i.e. [6,7] by position 1. Now  we saw the arrays limitations. Let's understand the advantages of the Linked List over array.  Advantage