Why You Need to Learn Algorithms
This was originally posted on Roberta’s Medium:
If you are interested in starting programming, the best way is to start from the basics just as when you are learning something new, you start from the scratch. First of all, What is Programming? Programming is the process of taking an algorithm and encoding it into a notation, a programming language, so that it can be executed by a computer. So then ……
What is an Algorithm?
Algorithm is a data structure describe the solution to a problem in terms of the data needed to represent the problem instance and the set of steps necessary to produce the intended result. It is essential to the way computers process data. This means that, without this, a computer can never process your commands. Hence, the need to learn it. Now let’s dive into it now. First let’s look at the various types of algorithms. Mind you, this article is not going to give you everything. It is just to introduce you into it and why I think we as programmers need it.
Types of Algorithms
Searching — A search algorithm is the step-by-step procedure used to locate specific data among a collection of data. It is considered a fundamental procedure in computing. In computer science, when searching for data, the difference between a fast application and a slower one often lies in the use of the proper search algorithm. There are two categories you’ll have to know which are : Linear and Binary.
- Linear Search : In this type of search, a sequential search is made over all items one by one. Every item is checked and if a match is found then that particular item is returned, otherwise the search continues till the end of the data collection like this.
- Binary Search: This search algorithm works on the principle of divide and conquer. In this type of search, it looks for a particular items and compares it with the middle most item of the collection. Here is a practical example.
Sorting — Sorting is arranging data in a particular format. Sorting algorithms specifies the order in which data is to be arranged. A scenario is when a user searches for a song and the title of these songs are listed in alphabetical order. This is done by sorting. Another example is creating a dictionary. You know words in a dictionary are arranged alphabetically, this could not be possible without sorting. There are a few types of sorting. These are :
- Bubble Sort: With this type of sorting, each pair of adjacent elements is compared and the elements are swapped if they are not in order. Due to its nature, it is not suitable for large data as it will take long to finish sorting. Let’s see how it works.
- Insertion Sort: This sorting technique deals with unordered or unsorted array. It checks linearly through the array list and reorders them in an ascending order. See how it works.
MergeSort– This sorting technique is based on divide and conquer. As the name implies merge, it first divides the data into equal halves and then combines them in a sorted manner.
There a lot more algorithms you could learn but these are just a few. Now imagine you are creating an application without any algorithm.. How do you think the program will work or serve your users properly.
Wrapping and Conclusion
Algorithms when used, helps you accomplish your tasks efficiently.Now, the decision is yours, become a skilled programmer or a novice.