The use of data structures and algorithms in real life
Published: 2022-07-17 06:38:41

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7x4eiqyfdc5equt55gp.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2yb6n4342oof3forzec.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xiivzlw83zk06yic19lq.png)
**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wv7f63jgqzxg9vfvslug.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7tuu0uke97d1i6oavve.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r76jtdo2djp7br74dsv4.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cm8qodunjue06ec4jci7.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wp2h889t6klfgmlsnc6.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zqa819we9qra62z48f0m.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cudybz5guin1p6ok16ff.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwo82o02pmych1z8856w.png)
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.