# Definition of an Algorithm

##### Rating:
(0)
Author: Devmountain Tutorials
##### Description:

Recognize the basic concept of an algorithm and how it is used in technology.

(more)

### Developing Effective Teams

*No strings attached. This college course is 100% free and is worth 1 semester credit.

37 Sophia partners guarantee credit transfer.

299 Institutions have accepted or given pre-approval for credit transfer.

* The American Council on Education's College Credit Recommendation Service (ACE Credit®) has evaluated and recommended college credit for 32 of Sophia’s online courses. Many different colleges and universities consider ACE CREDIT recommendations in determining the applicability to their course and degree programs.

Tutorial
what's covered
This section will explore the definition of an algorithm by discussing:
1. DEFINITION OF ALGORITHM
2. ALGORITHM EXAMPLE

In this unit, we’ll look briefly into some intermediate and advanced level concepts that pertain to the Web Developer career. This section is intended to expose you to things that you would otherwise not encounter if you hadn’t learned the basics of web development. We won’t go deep here- we just want to give you a sense of what it’s like to be a web developer once you have mastered the basics of the syntax of a language and the technologies of the web. You could say that this is where the artistry of the career starts to come into play. Beyond technological understanding, being a web developer is really creative and design-oriented. The challenges in this unit will uncover why.

## 1. DEFINITION OF ALGORITHM

It’s hard to read about technology in the news without hearing the term algorithm. So, it’s likely that most people, even those not working in technology, have a working definition of the term. This is a useful entry point.

Algorithms, at their highest level, are used for calculating or generating something that would normally take a lot of time and resources to figure out. An algorithm in it’s broadest sense is a repeatable set of instructions to follow that, when given an input or a set of inputs, can produce some useful output or set of outputs. An algorithm is like a recipe for calculating something that’s otherwise complex or difficult to produce.

Algorithms aren’t just technological- they can be completed by humans too. A cooking recipe is, in itself, an algorithm. There are inputs—ingredients, a set of instructions—how to mix, how long to bake something and at what temperature, and outputs—the delicious food to eat when you’re finished. But algorithms tend to deal with intellectual matter rather than solid matter.

We see algorithms for:

• Recommending things based on a user’s preferences (think of Netflix) *Mapping based on different transportation modes and preferred road types (think of GPS aps)
• Searching for information based on what Is likely to be most relevant (think of Googling something)
• Categorizing or identifying an unknown item based on its visual appearance (think of bird watching or star gazing apps)
• Predicting future behavior based on past behavior (think of the recommendations that you get on Amazon); and more!
There really is no limit to what an algorithm can attempt to do. What really matters, though, is how well an algorithm does what it sets out to do.

Algorithms have become technological because when we make complex processes into a repeatable set of steps, it’s possible to have a computer complete those steps.

This is exciting because it means that the creation of sophisticated algorithms can automate what would otherwise take a lot of time and effort for a human to complete. Many companies invest in the development of algorithms because there is value in providing automatic steps for complex processes.

terms to know

Algorithm
Algorithms are used for calculating or generating something that would normally take a lot of time and resources to figure out.

## 2. ALGORITHM EXAMPLE

In order to understand the way that algorithms are implemented using code, we’ll look at the example of the recommendation algorithm- the ability to take a user’s history and predict what products or content they would like to buy or see in the future.

The utility of recommendation algorithms is clear—almost any e-commerce or streaming platform will benefit greatly from being able to steer their users’ toward new products and content that they will enjoy.

In this example, we’ll imagine an e-commerce platform where people purchase makeup and skincare. The goal is to utilize a user’s past shopping history to make engaging recommendations on a user’s homepage for products that they might like to purchase next.

The input for the algorithm is the user profile that we are trying to recommend products for and the products that the user has purchased in the past.

The output for the algorithm is the set of the top five products to recommend to the user.

It’s worth noting here that the output for the algorithm is dynamic- it’s changing perhaps all the time, and is different from user to user. If it were the same all the time, or the same from every user, we might not require a computational algorithm to provide a recommendation.

These are the steps for two possible algorithms for recommending things based on a user’s preference.

### Algorithm Simple (A basic algorithm)

step by step
1. Look up the last product that the user purchased.
• If the user hasn’t purchased anything before, choose the top 5 most popular products in the entire store.
• If the user has purchased something, go a different route.
2. Choose four products from the same brand of the last product that they purchased that are closest in price to the last item they purchased.
3. Choose 1 product that is the same type of product (i.e. mascara, moisturizer) as the last product they purchased.

### Algorithm Complex (More steps, more accurate)

step by step
1. Look up the last product that the user purchased.
• If the user hasn’t purchased anything before, choose the top 5 most popular products in the entire store.
• f the user has purchased even one item, evaluate the user’s entire purchase history in relation to other users.
2. Reviewing all other users’ history, compare how similar others’ purchase history is to the user in question.
• A user with identical history will have a comparison estimation of 1.0. A user with completely different history will have a comparison estimation of -1.0. We will compute these coefficients using the Pearson correlation formula.
• Once we have the correlation scores for all other users against our user in question, we will find the products that users most similar to the user in question bought.
3. Starting with the most similar user (assuming that user has bought at least 5 products) we’ll recommend the top 5 most recent products that the user purchased.
4. If the top user hasn’t purchased 5 products, we’ll keep going down the list from most similar to least similar until we have 5 products.

After walking through the steps to create and use this recommendation algorithm, next time you are ordering something online, think about how many algorithms could be involved in each part of the ordering process.

Terms to Know
Algorithm

Algorithms are used for calculating or generating something that would normally take a lot of time and resources to figure out.

Rating