representation of data structures

The logical or mathematical model of a particular organization of data is called a data structure. The data structure is a way of storing and accessing the data into an acceptable form for computers. So that a large number of data is processed in a small interval of time. In a simple way, we say that storing the data in computer memory is called a data structure.

Types of Data Structure:-

A data structure can be broadly classified into

  • Primitive data structure
  • Non-primitive data structure

Primitive data structure

The data structures, typically those data structure that is directly operated upon by machine-level instructions i.e. the fundamental data types such as int, float, double incase of ā€˜Cā€™ are known as primitive data structures

Non-primitive data structure

The data structures, which are derived from primitive data structures called non-primitive data structures.

Representation of data structures

Data structure representation can be implemented in two ways.

They are: –

  • Sequential representation
  • Linked representation

Sequential representation

A sequential representation maintains the data in contiguous memory locations which takes less time to retrieve the data but leads to time complexity during insertion and deletion operations. Because of its sequential nature, the elements of the list must be freed, when we want to insert a new element or new data at a particular position of the list.

To acquire free space in the list, one must shift the data of the list towards the right side from the position where the data has to be inserted. Thus, the time taken by the CPU to shift the data will be much higher than the insertion operation and will lead to complexity in the algorithm. Similarly, while deleting an item from the list, one must shift the data items towards the left side of the list, which may waste CPU time.

A drawback of Sequential representation: – The major drawback of sequential representation is taking much time for insertion and deletion operations unnecessarily and increasing the complexity of the algorithm.

Linked Representation

Linked representation maintains the list by means of a link between the adjacent elements which need not be stored in contiguous memory locations. During insertion and deletion operations, links will be created or removed between which takes less time when compared to the corresponding operations of sequential representation.