The Uses of DSA in Real Life🤓
Published: 2022-09-17 05:42:21

---
title: The Uses of DSA in Real Life🤓
published: true
date: 2022-09-15 12:56:42 UTC
tags: 
canonical_url: https://blog.sagarmedtiya.me/the-uses-of-dsa-in-real-life
---
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3kal64yr2qry8v0go8k.gif)
Ever wondered why DSA is so much important in implementing software and as well as hiring process. Why the **companies** is primarily focused on taking DSA and not some specific **language/framework questions**?

Knowledge of DSA like **Tree, graphs, array** and various other algorithm goes a long way in solving problem efficiently with proper tool. Just like a car mechanic needs the right tool to fix a **car** and make it run properly, a programmer needs the right tool (algorithm and data structure) to make the software run properly. So the **interviewer** wants to find a candidate who can apply the right set of tools to solve the given problem.

_In this blog I'll share some examples of DSA used in real life. So, lets' get started with_ **array**

## Array

- 2D arrays, commonly known as, matrices, are used in image processing.
- Arrays can be used in speech processing where every speech signal is an array.
- In games like online chess, where the player can store his past moves as well as current moves. It indicates a hint of position. 
- It is also used in record management.
- Contacts on a cell phone.
- For CPU scheduling in computer.
- Your viewing screen is also a multidimensional array of pixels.

![Copy-of-arrays.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244404897/V9j-FjE_J.png)

## String

- Spam email detection.
- Plagiarism detection.

![pp-raffia-string-roll-5.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244461572/wKE2elVEV.jpg)

## Linked List

- Linked lists are used to display image containers. Users can visit past, current, and next images.
- They are used to store the history of the visited page.
- They are used to perform undo operations.
- Linked are used in software development where they indicate the correct syntax of a tag.
- Linked lists are used to display social media feeds.
- In a music playlist, songs are linked to the previous and next.
- Used in switching between applications and programs (Alt + Tab) in the Operating system (implemented using Circular Linked List)

![1_Failms_Mv7tZn65KSV-68A.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244514202/XrQ8eN0_a.png)

## Binary Search

- Finding Page Number in a book, e.g. Target page number is 35, you open at page no. 15, its less, you move ahead and open 43, it is greater, you again move backward.

![binary-search.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244766864/TSlKl28m_.png)

## Stacks

A queue is a data structure that uses LIFO order.

- Undo/Redo button/operation in word processors.
- Wearing/Removing Bangles.
- Pile of Dinner Plates.
- Stacked chairs.
- Changing wearables on a cold evening, first in, comes out at last.
- Last Hired, First Fired which is typically utilized when a company reduces its workforce in an economic recession.
- Loading bullets into the magazine of a gun. The last one to go in is fired first. Bam!
- Scratch cards earned after Google pay transaction.

![word-image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244817228/fgXFrdK1G.png)

## Queues

A queue is a data structure that uses FIFO order.

- In Escalators.
- Printer spooler.
- Sending emails.
- Car washes queue.
- Server while responding to requests.
- Operating System uses queues for job/task scheduling.
- Data packets in communication are arranged in queue format.
- Stack/Queue is used in the back and forward buttons of the web browser.
- While switching multiple applications, windows uses a circular queue.
- A circular queue is used to maintain the playing sequence of multiple players in a game.
- A queue can be implemented in Linked List-based Queue, Array-based Queue, Stack-based Queue.

![men-women-standing-long-queue-reception-3d-isometric-illustration_1284-55195.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244851943/WZhwKcO9v.jpg)

## Priority Queue

- Process scheduling in the kernel.
- Priority queues are used in file downloading operations in a browser.

![Introduction.webp](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244921890/7DbUw1Hhs.webp)

## Sorting Algorithm

- Order things by their value.
- Backend Databases (Merge Sort).
- Playing Cards with your friends (Insertion Sort).
- **sort()** uses IntroSort (a hybrid of Quicksort, Heapsort, and Insertion Sort), Faster than qsort().

![Sorting-Image.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244968337/LVGGtG7Ks.jpg)

## Graph

- Facebook, Instagram, and all social media networking sites, every user is Node, use the graph to suggest friends.
- The GPS navigation system also uses shortest path APIs. Google Maps, Apple Maps, and Bing Maps.
- Reacts virtual DOM uses graph data structures.
- MS Excel uses DAG (Directed Acyclic Graphs).
- Path Optimization Algorithms, BFS, DFS.
- Recommendation Engines.
- Scientific Computations.
- Flight Networks.
- Page ranking.

![1_IBtDZq0_4yWpXt0mhda0jw.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663245177597/RvgLuj_ES.png)

## Tree

- A decision-based algorithm is used in machine learning which works upon the algorithm of a tree.
- Databases also use B-Tree data structures for indexing.
- Domain Name Server (DNS) also uses tree structures.
- The file system of computer or mobile.
- Parsers(XML parser), Filesystem.
- Code Compression(zip).
- DOM in Html.
- Evaluate an expression (i.e., parse).
- Integral to compilers/automata theory.

![lllYzG60bDfxJ6CRQUI5FTjkqI7-acWR4vam2s901IU.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1663244600679/VvZybKxgd.jpg)

## Binary Search Tree

- 3D Game Engine.
- Computer Graphics Rendering.

![bst-vs-not-bst.webp](https://cdn.hashnode.com/res/hashnode/image/upload/v1663245335990/VNt-rPJOX.webp)

## Trie

- Dictionary application.
- Autocomplete feature in searching.
- Auto-completing the text and spells checking.

![Inkedlearnersbucket.com-1-1_LI.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1663245852068/UM8hKF47y.jpg)

## Hash Table

- Data stored in databases is generally of the key-value format which is done through hash tables.
- Social network feeds.
- Every time we type something to be searched in google chrome or other browsers, it generates the desired output based on the principle of hashing.
- Message Digest, a function of cryptography also uses hashing for creating output in such a manner that reaching the original input from that generated output is almost next to impossible.
- In our computers we have various files stored in it, each file has two very crucial information that is, filename and file path, in order to make a connection between the filename to its corresponding file path hash tables are used.
- Password hashing.
- Used for fast data lookup symbol table for compilers, database indexing, caches, Unique data representation.

![hash-table.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663245511574/P27Pkll0C.png)

## Heap

- Systems concerned with security and embedded systems such as Linux Kernel uses Heap Sort because of the O( n log(n) ).
- If we are stuck in finding the K-th smallest (or largest) value of a number then heaps can solve the problem in an easy and fast manner.
- Used by JVM (Java Virtual Machine) to store Java objects.

![1mghTRv.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663245917682/V4cKMYlvM.png)

## Greedy Algorithm

- Dijkstra algorithm.
- Shopping on a tight budget but want to buy gifts for all family members.
- Prims and Kruskals algorithms are used for finding the minimum spanning trees.

![Thumbnail_Greedy_Problem.webp](https://cdn.hashnode.com/res/hashnode/image/upload/v1663246084831/MRnKKMVXu.webp)

## DIJKSTRA Algorithm

- Used in applications like Google Maps to find the shortest path in a graph.

![90Qwu.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663246205760/P_RHXvW6v.png)

## Dynamic Programming

- In Google Maps to find the shortest path between the source and the series of destinations (one by one) out of the various available paths.
- In networking to transfer data from a sender to various receivers in a sequential manner.

![5647129569656832.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663246318723/fnwudfhGg.png)

## Backtracking

- Suppose we are coding a chess-playing algorithm and at a certain point, the algorithm finds that a set of steps fails to win. In this situation, the algorithm will reverse back to the safe state and try another possible set of steps.
- Sudoku solver
- 2048 game

![ba-state-space-tree.webp](https://cdn.hashnode.com/res/hashnode/image/upload/v1663246355494/0WJIN21Vd.webp)

_Note I cannot claim 100% copyright on the content, some examples are taken from other sources over Quora(Igor Markov)._

Thanks for reading.💗 Connect me on [LinkedIn](https://www.linkedin.com/in/sagar-medtiya/)