Dhanush DV
3 min readJan 19, 2021

--

Okay we have seen the types of Data Structures

Now, we will learn about the 1st Linear data Structure i.e an Array

If you have the basic knowledge of Arrays, i.e Syntax and it’s types, then we can talk about its Advantages and Disadvantages

Advantages :

  1. Similar data elements – All the elements in an array are of same type.
  2. Access any element easily through it’s index.
  3. Used in the implementation of Stacks and Queues.
  4. Suitable when number of elements are already known.

Disadvantages :

a) Static Memory Allocation – memory for the elements are allocated at Compile time. We cannot increase or decrease the size of the array once allocated.

b) Insertion and Deletion of elements in an array – It is somewhat difficult to add a new element to an array at any position other than ending of the list. We have to shift/move all the elements in the right part of the index position where the new element is to be added.

Example : if we want to insert an element ‘8’ in this array

we have to shift all the elements after ‘7’ to one step right and the final element is to be discarded

Hence we have the concept of Linked Lists.

You might think, why do we require a new concept called Linked Lists, if there are more advantages than disadvantages for Arrays.

This is the point where we need to know that how important these 2 drawbacks are…..

In Linked Lists, the memory is allocated Dynamically i.e allocating memory at run time due to which we can alter the size of the List according to the user.

NOTE: Whatever you learn, it should satisfy the customer(user) when you implement it.

Insertion and Deletion of elements is very easy when compared to arrays.

Advantages of Linked Lists are

  • There will no wastage of memory, since they are dynamically allocated.
  • It can store any type of data in it i.e Heterogeneous
  • Insertion and Deletion is easy
  • In the implementation of Stacks and Queues

Now, let’s see how a Linked List looks like:

This is how a Linked List look. It consists of 2 parts :

  1. Data part
  2. Link part – to link the address part of the next node

We will discuss everything in detail…….. in the coming articles

--

--

Dhanush DV
0 Followers

Hii there, I am B.Tech student who is very enthusiastic to learn new things about the tech and finding resources to learn them