How do algorithms work?
Much of what we do in our day-to-day lives comprises an algorithm: a sequence of step-by-step instructions geared to garner results. In the digital sphere, algorithms are everywhere. They’re the key component of any computer program, built into operating systems to ensure our devices adhere to the correct commands and deliver the right results on request.
An algorithm is a coded formula written into software that, when triggered, prompts the tech to take relevant action to solve a problem. Computer algorithms work via input and output. When data is entered, the system analyses the information given and executes the correct commands to produce the desired result. For example, a search algorithm responds to our search query by working to retrieve the relevant information stored within the data structure.
There are three constructs to an algorithm.
- Linear sequence: The algorithm progresses through tasks or statements, one after the other.
- Conditional: The algorithm makes a decision between two courses of action, based on the conditions set, i.e. if X is equal to 10 then do Y.
- Loop: The algorithm is made up of a sequence of statements that are repeated a number of times.
The purpose of any algorithm is to eliminate human error and to arrive at the best solution, time and time again, as quickly and efficiently as possible. Useful for tech users, but essential for data scientists, developers, analysts and statisticians, whose work relies on the extraction, organisation and application of complex data sets.
Types of algorithm
Brute force algorithm
Direct and straight to the point, the brute force algorithm is the simplest but the most applicable, eliminating incorrect solutions based on trial and error.
Recursive algorithms repeat the same steps until the problem is solved.
Using a combination of the brute force and recursive approach, a backtracking algorithm builds a data set of all possible solutions incrementally. As the name suggests, when a roadblock is reached, the algorithm retraces or ‘undoes’ its last step and pursues other pathways until a satisfactory result is reached.
All about getting more juice for the squeeze, greedy algorithms are employed to source and select the optimal solution to a problem. They typically extract the most obvious and immediate information in minimum time, enabling devices to sort through data quickly and efficiently. This algorithm is great for organising complex workflows, schedules or events programmes, for example.
Dynamic programming algorithm
A dynamic programming algorithm remembers the outcome of a previous run, and uses this information to arrive at new results. Applicable to more complex problems, the algorithm solves multiple smaller subproblems first, storing the solutions for future reference.
Divide and conquer algorithm
Similar to dynamic programming, this algorithm divides the problem into smaller parts. When the subproblems are solved, their solutions are considered together and combined to produce a final result.
Are algorithms artificial intelligence?
Algorithms define the process of decision-making, whereas artificial intelligence uses data to actually make a decision.
If a computer algorithm is simply a strand of coded instructions for completing a task or solving a problem, artificial intelligence is more of a complex web, comprising groups of algorithms and advancing this automation even more. Continuously learning from the accumulated data, artificial intelligence is able to improve, modify and create further algorithms to produce other unique solutions and strengthen the result. The output is not defined, as with algorithms, but designated. In this way, artificial intelligence enables machines to mimic the complex problem-solving abilities of the human mind.
Artificial intelligence algorithms are what determine your Netflix recommendations and recognise your friends in Facebook photos. They are also called learning algorithms, and typically fall into three types: supervised learning, unsupervised learning and reinforcement learning.
Supervised learning algorithms
In this instance, programmers feed training data (or ‘structured’ data sets) into the computer, complete with input and predictors, and show the machine the correct answers. The system learns to recognise the relational patterns and deduce the right results automatically, based on previous outcomes.
Unsupervised learning algorithms
This is where machine learning starts to speak for itself. A computer is trained with unlabeled (or ‘raw’) input data, and learns to mine for rules, detect patterns and summarise and group data points to help better describe the data to users. The algorithm is used to derive meaningful insights from the data, even if the human expert doesn’t know what they’re looking for.
Reinforcement learning algorithms
This branch of algorithm learns from interactions with the environment, utilising these observations to take actions that either maximise the reward or minimise the risk. Reinforcement learning algorithms allow machines to automatically determine the ideal behaviour within a specific context, in order to maximise its performance.
Artificial intelligence algorithms in action
From artificial intelligence powered smartphone apps to autonomous vehicles, artificial intelligence is embedded into our digital reality in a multitude of big and small ways.
Facial recognition software is what enables you to log in to your device in the first place, while apps such as Google Maps and Uber analyse location-based data to map routes, calculate journey times and fares and predict traffic incidents.
From targeted ads to personalised shopping, artificial intelligence algorithms are working to optimise our online experiences, while future applications will see the installation of self-driving cars and artificial intelligence autopilots.
Unmask the secrets of data science
Data is being collected at unprecedented speed and scale, becoming an ever-increasing part of modern life. While ‘big data’ is big business, it is of little use without big insight. The skills required to develop such insight are in short supply, and the expertise needed to extract information and value from today’s data couldn’t be more in demand.
Study the University of York’s 100% online MSc in Computer Science with Data Analytics and enhance your skills in computational thinking, problem-solving and software development, while advancing your knowledge of machine learning, data analytics, data mining and text analysis. Armed with this sought-after specialist knowledge, you’ll graduate the course with an abundance of career prospects in this lucrative field.