## Introduction to Algorithm

In this topic, we have discussed the introduction to the Algorithm, which represents the way to solve any problem. It is essential to understand how a common man applying the algorithm everywhere to complete any work in day-to-day life; itâ€™s very common. Itâ€™s very compulsory to complete the work effectively. Suppose a farmer sells a crop in the market and earns some money; many cases occur where the farmer will think about the best approach with a huge profit.

The farmer will check the market price, Size of the market, demand-supply, and the farmer will also think about how to sell the crop either per Kg or per quintal to make more profit here the farmer is also applying some logic and algorithm to complete the work ineffective way to get more profit these ideas came from experience and challenges faced by the same or other farmers. In technical terms, if we talk about any programming language without any algorithm, itâ€™s not possible to write any effective logic.

Before writing any logic in any programming language, we should think about the below things.

**The correctness of the program**: In any conditions, your output should be correct; before applying any algorithm, make sure your output is cent percent correct; otherwise, there is no meaning of the algorithm or your program.**Time**: Time is essential everywhere; you just have to take care of how much time your algorithm is taking to complete the work.**Complexity:**How much is your algorithm complicated in terms of logic, the time is taken, and the memory used to complete the work?

### Components of Algorithm

As we have discussed earlier in an introduction to algorithms that it has different components, which differ from each other in different situations.

Generally, algorithms comprise four components:

#### 1. Input or Feedback

As we know, algorithms are sequences of steps to be followed to get some output; we need to provide some inputs to an algorithm; one good example from daily life is when we need sugar as output, we have to give sugarcane as input. These days, smartphones are coming with a face lock where you have to come in front of the camera and your face will be taken as input, and the algorithm will judge your face by using your face cut, wrinkles, Hairs, and different parameters, then compares with stored face, which was given first time to mobile.

#### 2. Sequence of Algorithms

After having inputs and introduction to algorithms, then the next step to follow is the sequencing of steps present in the algorithm; according to what output we want, we have to arrange steps present in the algorithm.

**Condition:**Sometimes we have to check conditions according to input; as an example, IRCTC(Indian railway ticket booking app) checks if a person is eligible for a discount on the basis of age by using the Age as input algorithm checks if the person is above 65 or not. If a person is above 65, then he will be eligible for a discount. Otherwise, not.**Repetition:**Sometimes there are steps, which we have to repeat until the reaches of desired outputs. For example, if I want to search a record in files, we have to compare our input with different files until we find out our desired output; in this case, the same steps are repeated until the output(Files).

### Applications of Algorithm

If an employee is coming from the office, he will think to reach home as soon as possible, and he will try to take the shortest path to cover the distance.

Below is some very important use case where the algorithm has been used.

- If you are searching for any item on any shopping site next time, you will get a similar type of item as a suggestion.
- If you are watching any video on YouTube next time, you will get similar type suggestions as recommended video for you.
- Have you thought about how the Google search engine works and why within seconds, results appear?
- In the same way, if we used Facebook, we will get the friend’s suggestions on the basis of some keys like School Name, College Name, Places, etc.

### Recommender System

Nowadays, it is very common in our day-to-day life everywhere recommender system is working directly or indirectly according to the activities, and it is very beneficial for both provider and user.

** Example:** If you are searching for any shoes on Amazon and next time you will get recommendations of similar type of shoes as suggestions it will very easy for you to select item and for the Amazon as well there is a very good chance that you can get buy shoes and on the basis of userâ€™s data recommender system work, and behind this recommender system machine learning algorithm works.

### Characteristics of Algorithm

Below are the characteristics mentioned:

**Finiteness:**An algorithm should be complete at one particular time, and this is very important for any algorithm; otherwise, your algorithm will go in an infinite state, and it will not be complete ever.**Definiteness:**Each algorithm should be clear and unambiguous.**Effectiveness:**Each line of an algorithm should be essentials. We should try to write in a simple way so it would be basic.**Input:**Every algorithm should take input; it can be Zero or one or more. So, according to the conditions, the user can use it.**Output:**For any work, some output should come; this is a must; otherwise, there is no meaning of any work. In the same way, each algorithm should generate one or more outputs.**Generality:**The algorithm should be common for the set of input and requirements so the same algorithm can apply in multiple places according to the userâ€™s requirements.

### Advantages and Disadvantage of Algorithms

Below are the advantages and disadvantages mentioned:

#### Advantages:

- The algorithms are very easy to understand and can be written in simple language, which anyone can understand.
- Algorithms can be broken down into different pieces, which will be easy to implement practically.
- By using algorithms, we can easily understand the sequence to be followed in processing.

#### Disadvantages:

- It isnâ€™t easy to convert a complex task into proper algorithms.
- It is a time-consuming process because we need to spend proper time writing the algorithm, and later, we need to implement it in a programming language.
- Itâ€™s complicated to show functionalities for each step of introduction to algorithms, and itâ€™s hard to understand each flow in the term for loop and branch.

### Recommended Articles

This has been a guide to Introduction to Algorithm. Here we have discuss introduction to algorithm with the basic points and characteristics. You may also look at the following articles to learn more –

- Data Structures And Algorithms Interview Questions
- Data Structures and Algorithms C++
- Algorithms and Cryptography
- Pattern Recognition Algorithms

Â Â 600+ Online CoursesÂ |Â Â 3000+ Hours |Â Â Verifiable Certificates |Â Â Lifetime Access

4.6

View Course

Related Courses