Types of Data Structure

By | August 23, 2019

In programming languages, we use data structures to provide a proper structure to our data. A data structure is basically used to collect and organize the data on which we are going to perform the operations.

For example, we all know what is an Array, one of the famous data structures, Arrays are used to collect similar data types and organize them in a linear structure. In a programming language, we require different data structure in order to make an effective program.

Similar in Object-Oriented programming we use the class to store different kinds of data types and functions(methods). There are many other data structures presents in programming world here we are going to discuss some of those.

Types of Data Structure

Data Structures are basically divided into two parts:

  • Primitive Data Structure
  • Non-Primitive Data Structure
Types of Data Structure
Primitive Data Structure Non-Primitive Data Structure
Integer Floating Points Number Character Pointer Linear Data Structure Non-Linear Data Structure File Data Structure
Array List Stack Queue Tree Graph

Primitive Data Structure

Primitive Data Structures are the basic data structures and most of those are built-in data structure in many high-level programming languages. Primitive data structures can be defined as Data types present in the programming languages. The main property of a primitive data structure is they can not be further divided.

Basic Types of Primitive Data Structure:

  • Integer: Integer holds all the integer values, basically all the positive and negative numbers without decimal. g. = 11
  • Floating Points Numbers: Floating point also cover all the real number positive as well as negative with the decimal point. E.g. = 11.0
  • Character: Character holds every character present in the computer it could be any number, alphabets or any special symbol but it would be represented inside the double or single inverted comma. Eg = ’$’
  • Pointers: Pointer used to hold the memory address of the data values.

Non-Primitive Data Structures:

Non-Primitive Data Structures are the complex Data Structures we use in the programming language. Mostly, all the Non-Primitive Data Structures are user-defined data structures, though many languages give in-built support for these data structures, yet they are considered as the user-defined data structure.

Non-Primitive Data Structure uses Primitive data structure to form a structure, that’s why it’s said that non-primitive data structures are derived from primitive data structures.

The main property of a Non-Primitive Data Structure is they can be further divided into primitive data Structure.

Types of Non-Primitive Data Structure:

There are 3 types of Non-Primitive Data Structure:

  • Linear Data Structure
  • Non-Linear Data Structure
  • Files Data Structure
Linear Data Structure:

In linear Data Structure elements stored in a sequential manner, it does not mean that they store in a linear or contiguous memory location.

Types of Linear Data Structure

The Linear Data Structure is further divided into 4 categories:

  • Array: Array is a homogeneous collection of elements, in simple words an array can store only similar Data type at once. Array store all the elements in a linear sequence and in a contiguous memory location.Due to storing elements in contiguous memory location the operation such as retrieving data element is very easy. There are many disadvantages of an array such as it can only store similar data type at once and not that much memory efficient when it’s come to an arbitrary number of elements.
  • List: The functionality of List is similar to Array, it also stores elements in a linear sequence. List uses dynamic memory allocation to store its elements in different memory locations. Though elements stored in different memory location but all are arranged in a sequence and one linked with another.
  • Stack: Stack is similar to list but if follow the LIFO principle to store and retrieve elements. LIFO stands for Last In First Out, which means the element stored last in the stack would be retrieved first. To perform the LIFO principle Stack, use two operations push and pop. push() used to insert an element in the stack. pop() used to retrieve an element from the stack.
  • Queues: Queue Data structure is just opposite of stack, it uses FIFO principle, FIFO stands for first in first out, in a queue the element stored first in the structure would be retrieved first.
Non-Linear Data Structure

In Non-Linear Data Structure the elements do not store in sequential order.

Types of Non-Linear Data Structure
  • Graph: Graph Data Structure used for networks representation. A graph data structure basically uses two components vertices and edges. In the graph, Edges are used to connect vertices.
  • Tree: Tree uses a hierarchical form of structure to represent its elements. One of the famous tree Data structures is Binary tree. A tree uses a node-like structure to make a hierarchical form, where each node represents a value. The uppermost node of the tree is known as the root node and the bottom node is known as a leaf node. Tree data structure are the complex data structure we use in the programming, and it used to solve many real-time problems.

File Data Structure

File is a collection of records, using a file we can store data in txt format. Many programming languages come with a built-in file handling structure.

We can perform the read, write and append operation on files, so we could add and retrieve data from it. File is the easiest method of creating and retrieving data, but it is not productive when it comes to a huge amount of data.

Conclusion

Data Structures are the most important part of a programming language and in tech interview the favorite topic of the interviewer. The ability to choose the right data structure is one of the vital skills a programmer should possess.

In a big project or further development of the programming, we require those developers who have complete knowledge of all basic data structure and able to manipulate them in order to make them more efficient. 

People Also Read:

Leave a Reply

Your email address will not be published. Required fields are marked *