Introduction
This particular introduction is about how DS and Algo can be applied in real life. So sit tight grab a cup of coffee and let's see how DS and Algo are applied in real life.
Here's a way I often like to think. Many algorithms proceed in a series of steps that are all the same. To understand an algorithm, think about what the situation is somewhere in the middle of the algorithm's execution, and figure out what action a single step does.
- For example, if we're partway through Insertion Sort, we have an array with a sorted part and an unsorted part. A single step does this: take the first item from the unsorted part and insert it into the sorted part, thus making the sorted part one item larger.
- In Dijkstra's Algorithm, we are given a start vertex. Halfway through, we have a set of vertices whose distances from the start vertex are known, and a set whose distances are unknown. A single step takes an unknown vertex and makes it known. The vertex chosen is an unknown vertex y with a known neighbor x so that the following is as small as possible: (known distance from start to x) plus (length of edge xy). And that small number becomes the known distance from start to y. As for why it works, think about y. Is there any way we could find a shorter path from start to y? At some point, this path would need to go from a known vertex to an unknown vertex. But that unknown vertex would have to be farther from start than y is, since we chose y to make the above number as small as possible. So, no, there is no shorter path to y. So the distance to y is correct. And that means the whole algorithm is correct.
- This way of thinking can be helpful for understanding iterative algorithms. It isn't so good for recursive algorithms. Thinking about (say) Merge Sort in this way is probably not a good thing.
Arrays and Matrices
- 2D arrays (as matrix), are used in image processing.
- To Store a raster graphics (1000 by 1000 pixels) as a bitmap.
- Your viewing screen is also a multidimensional array of pixels.
- In an online exam question paper numbering.
- Sudoku or Chess Board are 2D arrays.
- It is also used in speech processing, in which each speech signal is an array.
- Arrangement of leader-board of a game.
- Book titles in a Library Management Systems.
- Online ticket booking.
- Contacts on a cell phone.
- In geology, matrices are used for making seismic surveys.
- Used for plotting graphs, statistics, surveys, and also to do scientific studies and research in almost different fields.