# REAL LIFE APPLICATIONS OF SORTING ALGORITHMS

Starting off with a basic question, **what are algorithms**? According to Google, “*algorithms are a finite sequence of well-defined instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing calculations and data processing.*” Basically, they are making our work easier, and sometimes our exams difficult!

Jokes aside, algorithms in data structures are very crucial for many reasons and they are of many types, some of them being

- Quick sort
- Merge sort
- Bubble sort
- Heap sort

Another question that might arise is **why do we need algorithms**?

- Algorithms help execute tasks smoothly, accurately and efficiently
- They are a crucial part of computer science and assist in problem solving
- Make sure that the computer completes the work in the best way possible

While algorithms are fun to study and understand, we tend to not notice the real life, day to day applications of algorithms. They often are all around us and we don’t end up noticing the math in nature!

# Here, let’s look at the real life applications of different algorithms

*Traffic signals*

How many times have you wondered if there is someone controlling the traffic lights all day long? Well, we all have been there as kids! Behind the lights there is an algorithm that controls the colors and the time phases. For our safety, traffic lines check the traffic density and time to change the lights to avoid the congestion of vehicles for a long time.

*Recipes*

As easy as it might sound, recipes are too the simplest form of algorithms. They are basically a step by step instruction manual for reaching the desired result. They are efficient and ensure that the end goal is achieved successfully.

*Google maps*

We all have used this function some or the other day and it has been a great help to us by giving us the shortest path to our destination and also the traffic on it. Google Maps uses the shortest path algorithm- Dijkstra’s algorithm. It uses this algo to connect two points on the map and provides us with the quickest way possible.

# Explanation of Dijkstra’s Algorithm

Let the node at which we’re starting be known as the initial node. let the space of node Y be the distance from the initial node to Y. Dijkstra’s algorithm will initially start with endless distances and could try to enhance them grade by grade.

Mark all nodes unvisited. Create a hard and fast of all the unvisited nodes called the unvisited set.

- Assign to each node a tentative distance cost: set it to zero for our initial node and to infinity for all different nodes. The tentative distance of a node v is the period of the shortest course located so far among the node v and the starting node. given that first of all no path is understood to any other vertex than the supply itself (that’s a course of duration zero), all other tentative distances are initially set to infinity. Set the preliminary node as current.
- For the modern-day node, remember all of its unvisited acquaintances and calculate their tentative distances via the current node. compare the newly calculated tentative distance to the modern-day assigned value and assign the smaller one.
- As an example, if the present day node A is marked with a distance of 6, and the threshold connecting it with a neighbor B has length 2, then the gap to B via A may be 6 + 2 = 8. If B turned into previously marked with a distance greater than 8 then trade it to eight. otherwise, the modern-day fee might be saved.

Whilst we’re completely thinking about all of the unvisited buddies of the cutting-edge node, mark the present day node as visited and remove it from the unvisited set. A visited node will never be checked again.

If the destination node has been marked visited (while making plans a route among unique nodes) or if the smallest tentative distance a few of the nodes in the unvisited set is infinity (when planning a complete traversal; occurs when there’s no connection among the preliminary node and closing unvisited nodes), then stop. The set of rules has finished.

Otherwise, pick the unvisited node that is marked with the smallest tentative distance, set it as the new modern-day node, and pass back to step three.

While making plans a route, it’s far genuinely no longer important to wait till the vacation spot node is “visited” as above: the algorithm can forestall once the vacation spot node has the smallest tentative distance among all “unvisited” nodes (and for this reason may be decided on as the next “cutting-edge”)

*Spotify*

Our favorite music playing apps have evolved so much during the years. First we used to search for songs and make a playlist. However, in Spotify and now in many other similar apps, when you search for a song, they automatically queue similar songs and auto-play them. This way, you don’t have to change the song everytime and can enjoy the music. Now, there’s nothing but an algorithm behind this too that checks the amount of time you spend on a song and detects whether you like it or not.

*Bus schedules*

As all the above, this also uses algorithms. When the bus will come, how long will it wait, when it will depart, all of these are running on a set of fixed schedules and cannot be tampered with. Along with this, algorithms also define the shortest path that will be liable to the bus while saving time and fuel as well. (Eg: school buses)

From this we can conclude that algorithms are not only in books and for numericals, they actually are present everywhere in our day to day life. What are some of the algorithms you have noticed around you?