DEV Community

Cover image for The use of data structures and algorithms in real life
Rakesh Kumawat
Rakesh Kumawat

Posted on

The use of data structures and algorithms in real life

A data structure is a method of arranging data in a computer that allows it to be used effectively. Let's see the different types of data structures used in real-life.

Arrays
Arrays
It is most used data structure. It is used in every possible situation where you need to gather similar objects at one place.

Applications of Arrays

  1. The contact applications in our phone which we use in our daily life has a lot of contacts. These contacts are stored in the form of an arrays. When we add or delete a contact it is similar to inserting/deleting an array.
  2. Songs playlist in our music player.
  3. These are also used in the online ticket booking system if a user wants to book a seat in S-9, the array becomes seat[S][9].

Hash Table
Hash Table
Hash Table only store data that has a key associated with it. Operations like Inserting and Searching are easily manageable while using Hash Tables.

Applications of Hash Table

  1. They can be used to implement caches mainly used to that are used to speed up the access to data.
  2. Hash is a not just used in data structure, but also widely used in security, cryptography, graphics, audio.
  3. The hash functions are used in various algorithms to make their updating and storing computing faster.

Linked Lists
Linked Lists
Single Linked List
Collection of element called nodes that are stored haphazardly in the memory. Node has two parts. One which store data at a specific address and the other is a pointer that contains the address of the next node. The last node contains the pointer to NULL.

Applications of Single Linked List

  1. UNDO, REDO or DELETE operations
  2. Viewing photos continuously one after the other in a photo viewer.
  3. Skip to the next track option in a music player.

Double Linked List
It is a type of linked list in which a node contains a pointer to the previous and the next node in a sequence.

Applications of Double Linked List

  1. It is usually used in card games to represent the deck of cards.
  2. Implementing backward and forward navigation in the web browsers.
  3. UNDO and REDO functions in notepad or some other applications.

Stack
Stack
A Stack is defined as a linear list in which insertions and deletions take place at the same end based on the Last-In-First-Out(LIFO) strategy. This end is called the top of the stack and the other end is called the bottom of the stack.

Applications of Stack

  1. To check for left and right parenthesis match in an expression.
  2. To evaluate a post fix expression.
  3. Store the return address in a function call-return structure of a compiler.

Queues
Queues
A queues is a linear list in which additions and deletions take place at two different ends. Insertions take place at the rear end and deletions take place in the front-end.

Applications of Queues

  1. Priority queues are used in browser while downloading multiple files.
  2. Used by printer software.
  3. CPU for task scheduling.

Trees
Trees
Trees are hierarchical structures that have a single root node.

Applications of Trees

  1. Implementation of navigation in website or applications.
  2. Trees structures are also used in Domain Name Server(DNS).
  3. In various games which come across decision-making steps.

Graphs

Graphs
A graphs in which every edge is directed is called a digraph. A graph in which every edge is undirected is called a undirected graph or simply a graph.

Applications of Graphs

  1. The shortest path between two points can be found using graphs.
  2. Used in various e-commerce websites for user preferences.
  3. Used by Network-based platforms for interconnections.

Recursion

Recursion
The process in which a function calls itself directly or indirectly is called recursion and corresponding function is called a recursion function.

Properties

  1. Performing the same operations multiple times with different inputs
  2. In every step, we try smaller inputs to make the problem smaller
  3. Base condition is needed to stop the recursion otherwise infinite loop will occur

Sorting

Sorting
A Sorting Algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements.

Properties

  1. Space complexity
  2. Adaptability
  3. Speed for better time complexity

Searching

Searching
Searching Algorithms are designed to check for an element or retrieve an element from any data structure where it is sorted.

Dynamic Programming

Dynamic Programming
Dynamic Programming is a technique that breaks the problems into sub-problems, and saves the result for future purposes so that we do not need to compute the result again.

Top comments (0)