DEV Community

Cover image for Why Data Structures..
Abhiram
Abhiram

Posted on

Why Data Structures..

Data structures are used in computing to make it easy to locate and retrieve information.

Primitive data structures are simple ways for programming languages to represent basic values. These include data types like integer, char (character), Boolean, pointers, and the like.

Non-primitive data structures provide ways of storing multiple values in a single variable. These include arrays, linked lists, stacks, graphs, trees etc..

In each case, the way the data is "structured" makes it easy to retrieve or manipulate.

- They should be efficient. 
Data structures make programs more productive with regards to time. ...
- They should be reusable.
 Once a data structure is implemented, it needs to demonstrate
 an ability to be used for other, similar data needs. ...
- They should remain hidden.
Enter fullscreen mode Exit fullscreen mode

Types of Data Structure

Basically, data structures are divided into two categories:

  1. - Linear data structure
  2. - Non-linear data structure

Linear data structures

In linear data structures, the elements are arranged in sequence one after the other. Since elements are arranged in particular order, they are easy to implement.

Popular linear data structures are:
1. Array Data Structure

An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string. Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.

Image description

2. Stack Data Structure

Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO (Last In First Out) or FILO (First In Last Out). It works just like a pile of plates where the last plate kept on the pile will be removed first.

Image description

3. Queue Data Structure

The queue is a linear data structure used to represent a linear list. It allows insertion of an element to be done at one end and deletion of an element to be performed at the other end

Unlike stack, the queue data structure works in the FIFO principle where first element stored in the queue will be removed first.
Image description
4. Linked List Data Structure

A linked list is the most sought-after data structure when it comes to handling dynamic data elements. A linked list consists of a data element known as a node. And each node consists of two fields: one field has data, and in the second field, the node has an address that keeps a reference to the next node. Each node contains the data items and address to the next node.

Image description

Non linear data structures

Unlike linear data structures, elements in non-linear data structures are not in any sequence. Instead they are arranged in a hierarchical manner where one element will be connected to one or more elements.

1. Graph Data Structure

Graphs in data structures are used to address real-world problems in which it represents the problem area as a network like telephone networks, circuit networks, and social networks. For example, it can represent a single user as nodes or vertices in a telephone network, while the link between them via telephone represents edges.

In graph data structure, each node is called vertex and each vertex is connected to other vertices through edges.
Image description

2. Trees Data Structure

Among various real-world applications, the tree data structure is used to demonstrate relationships between different nodes with the parent-child hierarchy. It is also called a hierarchic data structure because of this. It is most popular for simplifying and speeding up searching and sorting.
Similar to a graph, a tree is also a collection of vertices and edges. However, in tree data structure, there can only be one edge between two vertices.
Image description

Top comments (0)