Have a language expert improve your writing

Check your paper for plagiarism in 10 minutes, generate your apa citations for free.

  • Knowledge Base
  • Using AI tools
  • What Is an Algorithm? | Definition & Examples

What Is an Algorithm? | Definition & Examples

Published on August 9, 2023 by Kassiani Nikolopoulou . Revised on August 29, 2023.

An algorithm is a set of steps for accomplishing a task or solving a problem. Typically, algorithms are executed by computers, but we also rely on algorithms in our daily lives. Each time we follow a particular step-by-step process, like making coffee in the morning or tying our shoelaces, we are in fact following an algorithm.

In the context of computer science , an algorithm is a mathematical process for solving a problem using a finite number of steps. Algorithms are a key component of any computer program and are the driving force behind various systems and applications, such as navigation systems, search engines, and music streaming services.

Instantly correct all language mistakes in your text

Upload your document to correct all your mistakes in minutes

upload-your-document-ai-proofreader

Table of contents

What is an algorithm, how do algorithms work, examples of algorithms, other interesting articles, frequently asked questions about algorithms.

An algorithm is a sequence of instructions that a computer must perform to solve a well-defined problem. It essentially defines what the computer needs to do and how to do it. Algorithms can instruct a computer how to perform a calculation, process data, or make a decision.

The best way to understand an algorithm is to think of it as a recipe that guides you through a series of well-defined actions to achieve a specific goal. Just like a recipe produces a replicable result, algorithms ensure consistent and reliable outcomes for a wide range of tasks in the digital realm.

And just like there are numerous ways to make, for example, chocolate chip cookies by following different steps or using slightly different ingredients, different algorithms can be designed to solve the same problem, with each taking a distinct approach but achieving the same result.

Algorithms are virtually everywhere around us. Examples include the following:

  • Search engines rely on algorithms to find and present relevant results as quickly as possible
  • Social media platforms use algorithms to prioritize the content that we see in our feeds, taking into account factors like our past behavior, the popularity of posts, and relevance.
  • With the help of algorithms, navigation apps determine the most efficient route for us to reach our destination.
  • It must be correct . In other words, it should take a given problem and provide the right answer or result, even if it stops working due to an error.
  • It must consist of clear, practical steps that can be completed in a limited time, whether by a person or the machine that must execute the algorithm. For example, the instructions in a cookie recipe might be considered sufficiently concrete for a human cook, but they would not be specific enough for programming an automated cookie-making machine.
  • There should be no confusion about which step comes next , even if choices must be made (e.g., when using “if” statements).
  • It must have a set number of steps (not an infinite number) that can be managed using loops (statements describing repeated actions or iterations).
  • It must eventually reach an endpoint and not get stuck in a never-ending loop.

Check for common mistakes

Use the best grammar checker available to check for common mistakes in your text.

Fix mistakes for free

Algorithms use a set of initial data or input , process it through a series of logical steps or rules, and produce the output (i.e., the outcome, decision, or result).

Algorithm boxes

If you want to make chocolate chip cookies, for instance, the input would be the ingredients and quantities, the process would be the recipe you choose to follow, and the output would be the cookies.

Algorithms are eventually expressed in a programming language that a computer can process. However, when an algorithm is being created, it will be people, not a computer, who will need to understand it. For this reason, as a first step, algorithms are written as plain instructions.

  • Input: the input data is a single-digit number (e.g., 5).
  • Transformation/processing: the algorithm takes the input (number 5) and performs the specific operation (i.e., multiplies the number by itself).
  • Output: the result of the calculation is the square of the input number, which, in this case, would be 25 (since 5 * 5 = 25).

We could express this as an algorithm in the following way:

Algorithm: Calculate the square of a number

  • Input the number (N) whose square you want to find.
  • Multiply the number (N) by itself.
  • Store the result of the multiplication in a variable (result).
  • Output the value of the variable (result), which represents the square of the input number.

It is important to keep in mind that an algorithm is not the same as a program or code. It is the logic or plan for solving a problem represented as a simple step-by-step description. Code is the implementation of the algorithm in a specific programming language (like C++ or Python), while a program is an implementation of code that instructs a computer on how to execute an algorithm and perform a task.

Instead of telling a computer exactly what to do, some algorithms allow computers to learn on their own and improve their performance on a specific task. These machine learning algorithms use data to identify patterns and make predictions or conduct data mining to uncover hidden insights in data that can inform business decisions.

Broadly speaking, there are three different types of algorithms:

  • Linear sequence algorithms follow a specific set or steps, one after the other. Just like following a recipe, each step depends on the success of the previous one.
  • For example, in the context of a cookie recipe, you would include the step “if the dough is too sticky, you might need to refrigerate it.”
  • For example, a looping algorithm could be used to handle the process of making multiple cookies from a single batch of dough. The algorithm would repeat a specific set of instructions to form and bake cookies until all the dough has been used.

Algorithms are fundamental tools for problem-solving in both the digital world and many real-life scenarios. Each time we try to solve a problem by breaking it down into smaller, manageable steps, we are in fact using algorithmic thinking.

  • Identify which clothes are clean.
  • Consider the weather forecast for the day.
  • Consider the occasion for which you are getting dressed (e.g., work or school etc.).
  • Consider personal preferences (e.g., style or which items match).

In mathematics, algorithms are standard methods for performing calculations or solving equations because they are efficient, reliable, and applicable to various situations.

Suppose you want to add the numbers 345 and 278. You would follow a set of steps (i.e., the standard algorithm for addition):

  • Write down the numbers so the digits align.
  • Start from the rightmost digits (the ones place) and add them together: 5 + 8 = 13. Write down the 3 and carry over the 1 to the next column.
  • Move to the next column (the tens place) and add the digits along with the carried-over value: 4 + 7 + 1 = 12. Write down the 2 and carry over the 1 to the next column.
  • Move to the leftmost column (the hundreds place) and add the digits along with the carried-over value: 3 + 2 + 1 = 6. Write down the 6.

The final result is 623

Algorithm calculation example

Navigation systems are another example of the use of algorithms. Such systems use algorithms to help you find the easiest and fastest route to your destination while avoiding traffic jams and roadblocks.

If you want to know more about ChatGPT, AI tools , fallacies , and research bias , make sure to check out some of our other articles with explanations and examples.

  • ChatGPT vs human editor
  • ChatGPT citations
  • Is ChatGPT trustworthy?
  • Using ChatGPT for your studies
  • Sunk cost fallacy
  • Straw man fallacy
  • Slippery slope fallacy
  • Red herring fallacy
  • Ecological fallacy
  • Logical fallacy

Research bias

  • Implicit bias
  • Framing bias
  • Cognitive bias
  • Optimism bias
  • Hawthorne effect
  • Unconscious bias

Don't submit your assignments before you do this

The academic proofreading tool has been trained on 1000s of academic texts. Making it the most accurate and reliable proofreading tool for students. Free citation check included.

a set of problem solving operations in a computer

Try for free

In computer science, an algorithm is a list of unambiguous instructions that specify successive steps to solve a problem or perform a task. Algorithms help computers execute tasks like playing games or sorting a list of numbers. In other words, computers use algorithms to understand what to do and give you the result you need.

Algorithms and artificial intelligence (AI) are not the same, however they are closely related.

  • Artificial intelligence is a broad term describing computer systems performing tasks usually associated with human intelligence like decision-making, pattern recognition, or learning from experience.
  • Algorithms are the instructions that AI uses to carry out these tasks, therefore we could say that algorithms are the building blocks of AI—even though AI involves more advanced capabilities beyond just following instructions.

Algorithms and computer programs are sometimes used interchangeably, but they refer to two distinct but interrelated concepts.

  • An algorithm is a step-by-step instruction for solving a problem that is precise yet general.
  • Computer programs are specific implementations of an algorithm in a specific programming language. In other words, the algorithm is the high-level description of an idea, while the program is the actual implementation of that idea.

Algorithms are valuable to us because they:

  • Form the basis of much of the technology we use in our daily lives, from mobile apps to search engines.
  • Power innovations in various industries that augment our abilities (e.g., AI assistants or medical diagnosis).
  • Help analyze large volumes of data, discover patterns and make informed decisions in a fast and efficient way, at a scale humans are simply not able to do.
  • Automate processes. By streamlining tasks, algorithms increase efficiency, reduce errors, and save valuable time.

Cite this Scribbr article

If you want to cite this source, you can copy and paste the citation or click the “Cite this Scribbr article” button to automatically add the citation to our free Citation Generator.

Nikolopoulou, K. (2023, August 29). What Is an Algorithm? | Definition & Examples. Scribbr. Retrieved September 12, 2024, from https://www.scribbr.com/ai-tools/what-is-an-algorithm/

Is this article helpful?

Kassiani Nikolopoulou

Kassiani Nikolopoulou

Other students also liked, what is deep learning | a beginner's guide, what is data mining | definition & techniques, what is machine learning | a beginner's guide, get unlimited documents corrected.

✔ Free APA citation check included ✔ Unlimited document corrections ✔ Specialized in correcting academic texts

  • Admiral “Amazing Grace” Hopper

Exploring the Intricacies of NP-Completeness in Computer Science

Understanding p vs np problems in computer science: a primer for beginners, understanding key theoretical frameworks in computer science: a beginner’s guide.

Learn Computer Science with Python

Learn Computer Science with Python

CS is a journey, not a destination

  • Foundations

Understanding Algorithms: The Key to Problem-Solving Mastery

a set of problem solving operations in a computer

The world of computer science is a fascinating realm, where intricate concepts and technologies continuously shape the way we interact with machines. Among the vast array of ideas and principles, few are as fundamental and essential as algorithms. These powerful tools serve as the building blocks of computation, enabling computers to solve problems, make decisions, and process vast amounts of data efficiently.

An algorithm can be thought of as a step-by-step procedure or a set of instructions designed to solve a specific problem or accomplish a particular task. It represents a systematic approach to finding solutions and provides a structured way to tackle complex computational challenges. Algorithms are at the heart of various applications, from simple calculations to sophisticated machine learning models and complex data analysis.

Understanding algorithms and their inner workings is crucial for anyone interested in computer science. They serve as the backbone of software development, powering the creation of innovative applications across numerous domains. By comprehending the concept of algorithms, aspiring computer science enthusiasts gain a powerful toolset to approach problem-solving and gain insight into the efficiency and performance of different computational methods.

In this article, we aim to provide a clear and accessible introduction to algorithms, focusing on their importance in problem-solving and exploring common types such as searching, sorting, and recursion. By delving into these topics, readers will gain a solid foundation in algorithmic thinking and discover the underlying principles that drive the functioning of modern computing systems. Whether you’re a beginner in the world of computer science or seeking to deepen your understanding, this article will equip you with the knowledge to navigate the fascinating world of algorithms.

What are Algorithms?

At its core, an algorithm is a systematic, step-by-step procedure or set of rules designed to solve a problem or perform a specific task. It provides clear instructions that, when followed meticulously, lead to the desired outcome.

Consider an algorithm to be akin to a recipe for your favorite dish. When you decide to cook, the recipe is your go-to guide. It lists out the ingredients you need, their exact quantities, and a detailed, step-by-step explanation of the process, from how to prepare the ingredients to how to mix them, and finally, the cooking process. It even provides an order for adding the ingredients and specific times for cooking to ensure the dish turns out perfect.

In the same vein, an algorithm, within the realm of computer science, provides an explicit series of instructions to accomplish a goal. This could be a simple goal like sorting a list of numbers in ascending order, a more complex task such as searching for a specific data point in a massive dataset, or even a highly complicated task like determining the shortest path between two points on a map (think Google Maps). No matter the complexity of the problem at hand, there’s always an algorithm working tirelessly behind the scenes to solve it.

Furthermore, algorithms aren’t limited to specific programming languages. They are universal and can be implemented in any language. This is why understanding the fundamental concept of algorithms can empower you to solve problems across various programming languages.

The Importance of Algorithms

Algorithms are indisputably the backbone of all computational operations. They’re a fundamental part of the digital world that we interact with daily. When you search for something on the web, an algorithm is tirelessly working behind the scenes to sift through millions, possibly billions, of web pages to bring you the most relevant results. When you use a GPS to find the fastest route to a location, an algorithm is computing all possible paths, factoring in variables like traffic and road conditions, to provide you the optimal route.

Consider the world of social media, where algorithms curate personalized feeds based on our previous interactions, or in streaming platforms where they recommend shows and movies based on our viewing habits. Every click, every like, every search, and every interaction is processed by algorithms to serve you a seamless digital experience.

In the realm of computer science and beyond, everything revolves around problem-solving, and algorithms are our most reliable problem-solving tools. They provide a structured approach to problem-solving, breaking down complex problems into manageable steps and ensuring that every eventuality is accounted for.

Moreover, an algorithm’s efficiency is not just a matter of preference but a necessity. Given that computers have finite resources — time, memory, and computational power — the algorithms we use need to be optimized to make the best possible use of these resources. Efficient algorithms are the ones that can perform tasks more quickly, using less memory, and provide solutions to complex problems that might be infeasible with less efficient alternatives.

In the context of massive datasets (the likes of which are common in our data-driven world), the difference between a poorly designed algorithm and an efficient one could be the difference between a solution that takes years to compute and one that takes mere seconds. Therefore, understanding, designing, and implementing efficient algorithms is a critical skill for any computer scientist or software engineer.

Hence, as a computer science beginner, you are starting a journey where algorithms will be your best allies — universal keys capable of unlocking solutions to a myriad of problems, big or small.

Common Types of Algorithms: Searching and Sorting

Two of the most ubiquitous types of algorithms that beginners often encounter are searching and sorting algorithms.

Searching algorithms are designed to retrieve specific information from a data structure, like an array or a database. A simple example is the linear search, which works by checking each element in the array until it finds the one it’s looking for. Although easy to understand, this method isn’t efficient for large datasets, which is where more complex algorithms like binary search come in.

Binary search, on the other hand, is like looking up a word in the dictionary. Instead of checking each word from beginning to end, you open the dictionary in the middle and see if the word you’re looking for should be on the left or right side, thereby reducing the search space by half with each step.

Sorting algorithms, meanwhile, are designed to arrange elements in a particular order. A simple sorting algorithm is bubble sort, which works by repeatedly swapping adjacent elements if they’re in the wrong order. Again, while straightforward, it’s not efficient for larger datasets. More advanced sorting algorithms, such as quicksort or mergesort, have been designed to sort large data collections more efficiently.

Diving Deeper: Graph and Dynamic Programming Algorithms

Building upon our understanding of searching and sorting algorithms, let’s delve into two other families of algorithms often encountered in computer science: graph algorithms and dynamic programming algorithms.

A graph is a mathematical structure that models the relationship between pairs of objects. Graphs consist of vertices (or nodes) and edges (where each edge connects a pair of vertices). Graphs are commonly used to represent real-world systems such as social networks, web pages, biological networks, and more.

Graph algorithms are designed to solve problems centered around these structures. Some common graph algorithms include:

Dynamic programming is a powerful method used in optimization problems, where the main problem is broken down into simpler, overlapping subproblems. The solutions to these subproblems are stored and reused to build up the solution to the main problem, saving computational effort.

Here are two common dynamic programming problems:

Understanding these algorithm families — searching, sorting, graph, and dynamic programming algorithms — not only equips you with powerful tools to solve a variety of complex problems but also serves as a springboard to dive deeper into the rich ocean of algorithms and computer science.

Recursion: A Powerful Technique

While searching and sorting represent specific problem domains, recursion is a broad technique used in a wide range of algorithms. Recursion involves breaking down a problem into smaller, more manageable parts, and a function calling itself to solve these smaller parts.

To visualize recursion, consider the task of calculating factorial of a number. The factorial of a number n (denoted as n! ) is the product of all positive integers less than or equal to n . For instance, the factorial of 5 ( 5! ) is 5 x 4 x 3 x 2 x 1 = 120 . A recursive algorithm for finding factorial of n would involve multiplying n by the factorial of n-1 . The function keeps calling itself with a smaller value of n each time until it reaches a point where n is equal to 1, at which point it starts returning values back up the chain.

Algorithms are truly the heart of computer science, transforming raw data into valuable information and insight. Understanding their functionality and purpose is key to progressing in your computer science journey. As you continue your exploration, remember that each algorithm you encounter, no matter how complex it may seem, is simply a step-by-step procedure to solve a problem.

We’ve just scratched the surface of the fascinating world of algorithms. With time, patience, and practice, you will learn to create your own algorithms and start solving problems with confidence and efficiency.

Related Articles

a set of problem solving operations in a computer

Three Elegant Algorithms Every Computer Science Beginner Should Know

What is an Algorithm? Algorithm Definition for Computer Science Beginners

Kolade Chris

If you’re a student and want to study computer science, or you’re learning to code, then there’s a chance you’ve heard of algorithms. Simply put, an algorithm is a set of instructions that performs a particular action.

Contrary to popular belief, an algorithm is not some piece of code that requires extremely advanced knowledge in order to implement. At the same time, I won't say that an algorithm is easy to implement, either. Some can be, but it depends on what you're trying to do.

In the end, the best way to get better at algorithms is by practicing them regularly.

In this article, you'll learn all about algorithms so you'll be prepared next time you encounter one, or have to write one yourself. I will also share some freeCodeCamp resources that will help you learn how to write algorithms in different languages.

What We'll Cover

What exactly is an algorithm.

  • Why Do You Need an Algorithm?

Types of Algorithms

  • Which Programming Language Is Best for Writing Algorithms? (rename)

Resources for Learning Algorithms

An algorithm is a set of steps for solving a known problem. Most algorithms are implemented to run following the four steps below:

  • take an input
  • access that input and make sure it's correct
  • show the result
  • terminate (the stage where the algorithm stop running)

Some steps of the algorithm may run repeatedly, but in the end, termination is what ends an algorithm.

For example, the algorithm below sort numbers in descending order. It loops through the numbers specified until it arranges them in descending order, then terminates when there are no more number to sort:

For a theoretical basis, for instance, an algorithm for dividing two numbers and showing the remainder could run through the steps below:

  • Step 1 : the user enters the first and second numbers – the dividend and the divisor
  • Step 2 : the algorithm written to perform the division takes in the number, then puts a division sign between the dividend and the divisor. It also checks for a remainder.
  • Step 3 : the result of the division and remainder is shown to the user
  • Step 4 : the algorithm terminates

Here's how that kind of algorithm is implemented in JavaScript:

If there's an error, the algorithm may not run, or might return the wrong output. If the programmer who wrote the algorithm took user experience into consideration, then an error handler could show an error to the user and let them know what to do.

Why do you Need an Algorithm?

If you’re one of those computer science students asking “why algorithms”, here are some reasons why you should learn about them:

Problem Solving : being able to write an algorithm improves your problem-solving capacity. It is a common belief that once you can solve a problem with one thing, you can solve problems with another closely related one. So, if you can solve problems with Python, you can solve problems with JavaScript.

Scalability : an algorithm helps your software/application/website respond appropriately to demands.

Proper Utilization of Resources: choosing the right algorithm ensures proper utilization of resources such as memory, storage, network, and others.

Algorithms in computer science can be broadly categorized into searching and sorting algorithms:

  • Sorting – selection sort, bubble sort, insertion sort, merge sort, quick sort, and so on.
  • Searching – binary search, exponential search, jump search, and so on.

But there are many types of algorithms that programers use regularly. Here are some other common algorithm types organized by category:

  • Hashing – SHA-256, SHA-1
  • Brute force – trial and error
  • Divide and conquer – merge sort algorithm
  • Greedy – Prim's algorithm, Kruskal's algorithm
  • Recursive – computer factorials

Which Programming Language Is Best for Writing Algorithms?

You can write angorithms in any programming language. There's no benefit to using one language over another.

Every language has its strengths and weaknesses, and each has unique syntax and features. So writing an algorithm might look different in one language compared to another.

But algorithms are universal concepts. So if you can write bubble sort in Python, you should also be able to write it in JavaScript or C#.

Here are some videos from the freeCodeCamp YouTube channel that can help you learn algorithms effectively:

  • Algorithms and Data Structures Tutorial - Full Course for Beginners
  • Algorithms in Python – Full Course for Beginners
  • Data Structures Easy to Advanced Course - Full Tutorial from a Google Engineer
  • Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges
  • Understanding Sorting Algorithms

Also, the interactive JavaScript Algorithms and Data Structures Certification on freeCodeCamp can give you a crash course in algorithmic thinking in JavaScript.

In this article, we went over what an algorithm is, their types, and resources for learning algorithms.

If you read this far, the next thing you should do is start learning algorithms with one or more of the resources listed in this article.

Thank you for reading.

I'm a software developer and tech writer focusing on frontend technologies

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Tutorial Playlist

Data structure tutorial, arrays in data structures: a guide with examples, all you need to know about two-dimensional arrays, all you need to know about a linked list in a data structure, the complete guide to implement a singly linked list, the ultimate guide to implement a doubly linked list, the fundamentals for understanding circular linked list, the ultimate guide to understand the differences between stack and queue, implementing stacks in data structures, your one-stop solution for stack implementation using array, your one-stop solution for queue implementation using array, your one-stop solution to learn depth-first search(dfs) algorithm from scratch, your one-stop solution for stack implementation using linked-list, the definitive guide to understand stack vs heap memory allocation.

All You Need to Know About Linear Search Algorithm

All You Need to Know About Breadth-First Search Algorithm

A one-stop solution for using binary search trees in data structure, the best tutorial to understand trees in data structure, a complete guide to implement binary tree in data structure, a holistic look at using avl trees in data structures, all you need to know about tree traversal in data structure, the best and easiest way to understand an algorithm, the best guide you’ll ever need to understand b-tree in data structure, the best guide you'll ever need to understand spanning tree in data structure, a one-stop solution guide to understand data structure and algorithm complexity, your one-stop solution to understand shell sort algorithm, your one-stop solution to quick sort algorithm, what is selection sort algorithm in data structures, everything you need to know about radix sort algorithm, everything you need to know about the counting sort algorithm, everything you need to know about the merge sort algorithm, insertion sort algorithm: one-stop solution that will help you understand insertion sort, everything you need to know about the bubble sort algorithm, the best guide you’ll ever need to understand bucket sort algorithm, your one-stop solution to understand recursive algorithm in programming, the definitive guide to understanding greedy algorithm, your one-stop solution to understand backtracking algorithm, the fundamentals of the bellman-ford algorithm, your one-stop solution for graphs in data structures, the best guide to understand and implement solutions for tower of hanoi puzzle, a simplified and complete guide to learn space and time complexity, all you need to know about the knapsack problem : your complete guide, the fibonacci series: mathematical and programming interpretation, the holistic look at longest common subsequence problem, the best article to understand what is dynamic programming, a guide to implement longest increasing subsequence using dynamic programming, a holistic guide to learn stop solution using dynamic programming, one stop solution to all the dynamic programming problems, understanding the fundamentals of binomial distribution, here’s all you need to know about minimum spanning tree in data structures, understanding the difference between array and linked list, the best article out there to understand the b+ tree in data structure, a comprehensive look at queue in data structure, your one-stop solution to understand coin change problem, the best way to understand the matrix chain multiplication problem, your one-stop solution to learn floyd-warshall algorithm for using dynamic programming, the best tutorial you'll ever need for queue implementation using linked list, all you need to know about how to create a react js portfolio project, the best guide to learn how to make a wireframe: what is a wireframe, the best dsa projects for your resume, top 5 best coding books you must read, the working and implementation of physical layer in the osi model, how to create an instagram clone using react, reactjs vs vuejs, what is an algorithm definition, types, characteristics.

Lesson 21 of 63

The Best and Easiest Way to Understand an Algorithm

Table of Contents

What is an algorithm.

An algorithm is a set of commands that must be followed for a computer to perform calculations or other problem-solving operations.According to its formal definition, an algorithm is a finite set of instructions carried out in a specific order to perform a particular task. It is not the entire program or code; it is simple logic to a problem represented as an informal description in the form of a flowchart or pseudocode.

what-is-an-algorithm-flowchart

  • Problem: A problem can be defined as a real-world problem or real-world instance problem for which you need to develop a program or set of instructions. An algorithm is a set of instructions. 
  • Algorithm: An algorithm is defined as a step-by-step process that will be designed for a problem.
  • Input: After designing an algorithm, the algorithm is given the necessary and desired inputs.
  • Processing unit: The input will be passed to the processing unit, producing the desired output.
  • Output: The outcome or result of the program is referred to as the output.

After defining what an algorithm is, you will now look at algorithm characteristics.

Want a Top Software Development Job? Start Here!

Want a Top Software Development Job? Start Here!

How do Algorithms Work?

Algorithms are step-by-step procedures designed to solve specific problems and perform tasks efficiently in the realm of computer science and mathematics. These powerful sets of instructions form the backbone of modern technology and govern everything from web searches to artificial intelligence. Here's how algorithms work:

Input: Algorithms take input data, which can be in various formats, such as numbers, text, or images.

Processing: The algorithm processes the input data through a series of logical and mathematical operations, manipulating and transforming it as needed.

Output: After the processing is complete, the algorithm produces an output, which could be a result, a decision, or some other meaningful information.

Efficiency: A key aspect of algorithms is their efficiency, aiming to accomplish tasks quickly and with minimal resources.

Optimization: Algorithm designers constantly seek ways to optimize their algorithms, making them faster and more reliable.

Implementation: Algorithms are implemented in various programming languages, enabling computers to execute them and produce desired outcomes.

What is the Need for Algorithms?

You require algorithms for the following reasons:

Scalability

It aids in your understanding of scalability. When you have a sizable real-world problem, you must break it down into small steps to analyze it quickly.

Performance

The real world is challenging to break down into smaller steps. If a problem can be easily divided into smaller steps, it indicates that the problem is feasible.

After understanding what is an algorithm, why you need an algorithm, you will look at how to write one using an example.

Use of the Algorithms

Algorithms are essential to many disciplines because they offer organized, practical answers to challenging issues. Here are a few significant applications of algorithms in various fields:

1. Data Analysis and Machine Learning

Algorithms are used in data analysis and machine learning to find patterns in big datasets and forecast outcomes. Thanks to machine learning methods like support vector machines, decision trees, and neural networks, computers can learn from data and improve over time. These techniques are essential for applications such as recommendation systems, natural language processing, and picture recognition.

2. Cryptography & Security

Cryptography algorithms safeguard data by using encryption and decryption techniques, guaranteeing safe data storage and communication. Algorithms such as SHA-256, AES, and RSA are commonly employed in data integrity maintenance, user authentication, and sensitive information security . These algorithms comprise the foundation of cybersecurity measures used in secure communications, data encryption, and online transactions.

3. Information Retrieval and Search Engines

Search engines can efficiently index and retrieve pertinent information thanks to search algorithms such as PageRank and Hummingbird. By prioritizing web pages according to their significance and relevancy, these algorithms assist users in locating the most relevant information available online. Effective search algorithms are necessary to manage the enormous volume of online information.

4. Optimization problems

Optimization methods are utilized to select the optimal answer from various options. In various industries, including banking, engineering, logistics, and artificial intelligence, sophisticated issues are resolved using methods like gradient descent, linear programming, and genetic algorithms. These algorithms increase productivity, reduce expenses, and optimize resources for operations and decision-making.

5. Genomics and medical diagnostics

Due to their ability to analyze medical images, forecast disease outbreaks, and recognize genetic changes, algorithms are indispensable in medical diagnostics. Personalized medicine has been transformed by machine learning algorithms, in particular, which enable the creation of customized treatment regimens based on each patient's unique genetic profile. Additionally, algorithms help to speed up the sequencing and interpretation of genomic data, improving biotechnology and genomics research.

Characteristics of an Algorithm

An algorithm is a methodical process used to solve a task or solve a problem. Several important factors impact an algorithm's effectiveness:

1. Finiteness

An algorithm must always have a finite number of steps before it ends. When the operation is finished, it must have a defined endpoint or output and not enter an endless loop .

2. Definiteness

An algorithm needs to have exact definitions for each step. Clear and straightforward directions ensure that every step is understood and can be taken easily.

An algorithm requires one or more inputs . The values that are first supplied to the algorithm before its processing are known as inputs. These inputs come from a predetermined range of acceptable values.

One or more outputs must be produced by an algorithm. The output is the outcome of the algorithm after every step has been completed. The relationship between the input and the result should be clear.

5. Effectiveness

An algorithm's stages must be sufficiently straightforward to be carried out in a finite time utilizing fundamental operations. With the resources at hand, every operation in the algorithm should be doable and practicable.

6. Generality

Rather than being limited to a single particular case , an algorithm should be able to solve a group of issues. It should offer a generic fix that manages a variety of inputs inside a predetermined range or domain.

Types of Algorithms

Brute Force Algorithm: A straightforward approach that exhaustively tries all possible solutions, suitable for small problem instances but may become impractical for larger ones due to its high time complexity.

Recursive Algorithm: A method that breaks a problem into smaller, similar subproblems and repeatedly applies itself to solve them until reaching a base case, making it effective for tasks with recursive structures.

Encryption Algorithm: Utilized to transform data into a secure, unreadable form using cryptographic techniques, ensuring confidentiality and privacy in digital communications and transactions.

Backtracking Algorithm: A trial-and-error technique used to explore potential solutions by undoing choices when they lead to an incorrect outcome, commonly employed in puzzles and optimization problems.

Searching Algorithm: Designed to find a specific target within a dataset, enabling efficient retrieval of information from sorted or unsorted collections.

Sorting Algorithm: Aimed at arranging elements in a specific order, like numerical or alphabetical, to enhance data organization and retrieval.

Hashing Algorithm: Converts data into a fixed-size hash value, enabling rapid data access and retrieval in hash tables, commonly used in databases and password storage.

Divide and Conquer Algorithm: Breaks a complex problem into smaller subproblems, solves them independently, and then combines their solutions to address the original problem effectively.

Greedy Algorithm: Makes locally optimal choices at each step in the hope of finding a global optimum, useful for optimization problems but may not always lead to the best solution.

Dynamic Programming Algorithm : Stores and reuses intermediate results to avoid redundant computations, enhancing the efficiency of solving complex problems.

Randomized Algorithm: Utilizes randomness in its steps to achieve a solution, often used in situations where an approximate or probabilistic answer suffices.

How to Write an Algorithm?

  • There are no well-defined standards for writing algorithms. It is, however, a problem that is resource-dependent. Algorithms are never written with a specific programming language in mind.
  • As you all know, basic code constructs such as loops like do, for, while, all programming languages share flow control such as if-else, and so on. An algorithm can be written using these common constructs.
  • Algorithms are typically written in a step-by-step fashion, but this is not always the case. Algorithm writing is a process that occurs after the problem domain has been well-defined. That is, you must be aware of the problem domain for which you are developing a solution.

Now, use an example to learn how to write algorithms.

Problem: Create an algorithm that multiplies two numbers and displays the output.

Step 1 − Start

Step 2 − declare three integers x, y & z

Step 3 − define values of x & y

Step 4 − multiply values of x & y

Step 5 − store result of step 4 to z

Step 6 − print z

Step 7 − Stop

Algorithms instruct programmers on how to write code. In addition, the algorithm can be written as:

Step 1 − Start mul

Step 2 − get values of x & y

Step 3 − z ← x * y

Step 4 − display z

Step 5 − Stop

In algorithm design and analysis, the second method is typically used to describe an algorithm. It allows the analyst to analyze the algorithm while ignoring all unwanted definitions easily. They can see which operations are being used and how the process is progressing. It is optional to write step numbers. To solve a given problem, you create an algorithm. A problem can be solved in a variety of ways.

how-to-write-an-algorithm_Example

As a result, many solution algorithms for a given problem can be derived. The following step is to evaluate the proposed solution algorithms and implement the most appropriate solution.

As you progress through this "what is an Algorithm" tutorial, you will learn about some of the components of an algorithm.

Factors of an Algorithm

The following are the factors to consider when designing an algorithm:

  • Modularity: This feature was perfectly designed for the algorithm if you are given a problem and break it down into small-small modules or small-small steps, which is a basic definition of an algorithm.
  • Correctness: An algorithm's correctness is defined as when the given inputs produce the desired output, indicating that the algorithm was designed correctly. An algorithm's analysis has been completed correctly.
  • Maintainability: It means that the algorithm should be designed in a straightforward, structured way so that when you redefine the algorithm, no significant changes are made to the algorithm.
  • Functionality: It takes into account various logical steps to solve a real-world problem.
  • Robustness: Robustness refers to an algorithm's ability to define your problem clearly.
  • User-friendly: If the algorithm is difficult to understand, the designer will not explain it to the programmer.
  • Simplicity: If an algorithm is simple, it is simple to understand.
  • Extensibility: Your algorithm should be extensible if another algorithm designer or programmer wants to use it.

You will now see why an algorithm is so essential after understanding some of its components.

Qualities of a Good Algorithm

  • Efficiency: A good algorithm should perform its task quickly and use minimal resources.
  • Correctness: It must produce the correct and accurate output for all valid inputs.
  • Clarity: The algorithm should be easy to understand and comprehend, making it maintainable and modifiable.
  • Scalability: It should handle larger data sets and problem sizes without a significant decrease in performance.
  • Reliability: The algorithm should consistently deliver correct results under different conditions and environments.
  • Optimality: Striving for the most efficient solution within the given problem constraints.
  • Robustness: Capable of handling unexpected inputs or errors gracefully without crashing.
  • Adaptability: Ideally, it can be applied to a range of related problems with minimal adjustments.
  • Simplicity: Keeping the algorithm as simple as possible while meeting its requirements, avoiding unnecessary complexity.

The Complexity of an Algorithm

The algorithm's performance can be measured in two ways:

Time Complexity

The amount of time required to complete an algorithm's execution is called time complexity. The big O notation is used to represent an algorithm's time complexity. The asymptotic notation for describing time complexity, in this case, is big O notation. The time complexity is calculated primarily by counting the number of steps required to complete the execution. Let us look at an example of time complexity.

mul = 1;

// Suppose you have to calculate the multiplication of n numbers.  

for i=1 to n  

mul = mul *1;  

// when the loop ends, then mul holds the multiplication of the n numbers  

return mul;  

The time complexity of the loop statement in the preceding code is at least n, and as the value of n escalates, so does the time complexity. While the code's complexity, i.e., returns mul, will be constant because its value is not dependent on the importance of n and will provide the result in a single step. The worst-time complexity is generally considered because it is the maximum time required for any given input size.

Space Complexity

The amount of space an algorithm requires to solve a problem and produce an output is called its space complexity. Space complexity, like time complexity, is expressed in big O notation.

The space is required for an algorithm for the following reasons:

  • To store program instructions.
  • To store track of constant values.
  • To store track of variable values.
  • To store track of function calls, jumping statements, and so on.

Space Complexity = Auxiliary Space + Input Size

Finally after understanding what is an algorithm, its analysis and approches, you will look at different types of algorithms.

Advantage and Disadvantages of Algorithms

Advantages of algorithms:.

  • Efficiency: Algorithms streamline processes, leading to faster and more optimized solutions.
  • Reproducibility: They yield consistent results when provided with the same inputs.
  • Problem-solving: Algorithms offer systematic approaches to tackle complex problems effectively.
  • Scalability: Many algorithms can handle larger datasets and scale with increasing input sizes.
  • Automation: They enable automation of tasks, reducing the need for manual intervention.

Disadvantages of Algorithms:

  • Complexity: Developing sophisticated algorithms can be challenging and time-consuming.
  • Limitations: Some problems may not have efficient algorithms, leading to suboptimal solutions.
  • Resource Intensive: Certain algorithms may require significant computational resources.
  • Inaccuracy: Inappropriate algorithm design or implementation can result in incorrect outputs.
  • Maintenance: As technology evolves, algorithms may require updates to stay relevant and effective.

Choose The Right Software Development Program

This table compares various courses offered by Simplilearn, based on several key features and details. The table provides an overview of the courses' duration, skills you will learn, additional benefits, among other important factors, to help learners make an informed decision about which course best suits their needs.

Program Name Full Stack Java Developer Career Bootcamp Automation Testing Masters Program Post Graduate Program in Full Stack Web Development Geo IN All Non-US University Simplilearn Simplilearn Caltech Course Duration 11 Months 11 Months 9 Months Coding Experience Required Basic Knowledge Basic Knowledge Basic Knowledge Skills You Will Learn 15+ Skills Including Core Java, SQL, AWS, ReactJS, etc. Java, AWS, API Testing, TDD, etc. Java, DevOps, AWS, HTML5, CSS3, etc. Additional Benefits Interview Preparation Exclusive Job Portal 200+ Hiring Partners Structured Guidance Learn From Experts Hands-on Training Caltech CTME Circle Membership Learn 30+ Tools and Skills 25 CEUs from Caltech CTME Cost $$ $$ $$$ Explore Program Explore Program Explore Program

In this tutorial, you learned what an algorithm is and what its characteristics are. After that, you took a look at why you need algorithms, how to write them, and how important they are. After you learned about the approaches and factors of an algorithm, you learned about complexity and types of algorithms.

Suppose you're searching for a more extensive study that goes beyond Software Development and covers the most in-demand programming languages and abilities today. In that case, Simplilearn's Post Graduate Program In Full Stack Web Development  is the right choice for you. Explore this globally-recognized bootcamp program and be rest assured that completing this will  be the smartest move you can make to enter and grow in the software development profession.

Do you have any questions about this tutorial on what an algorithm is? If you do, please leave them in the comments section at the bottom of this page. Our specialists will respond to your questions as quickly as possible!

Find our Full Stack Java Developer Online Bootcamp in top cities:

NameDatePlace
Cohort starts on 2nd Oct 2024,
Weekend batch
Your City

About the Author

Soni Upadhyay

Soni Upadhyay is with Simplilearn's Research Analysis Team. She's a Computer Science and Engineering graduate. Programming languages are her area of expertise. She has a brilliant knowledge of C, C++, and Java Programming languages

Recommended Programs

Full Stack Java Developer Masters Program

Automation Testing Masters Program

Python Training

*Lifetime access to high-quality, self-paced e-learning content.

Recommended Resources

What Is Dijkstra’s Algorithm and Implementing the Algorithm through a Complex Example

What Is Dijkstra’s Algorithm and Implementing the Algorithm through a Complex Example

Secret to Unlocking Tableau's Hidden Potential

Secret to Unlocking Tableau's Hidden Potential

A* Algorithm : An Introduction To The Powerful Search Algorithm

A* Algorithm : An Introduction To The Powerful Search Algorithm

Random Forest Algorithm

Random Forest Algorithm

All You Need to Know About Linear Search Algorithm

Free eBook: Ethical Hacking Salary Report

  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.

Problems, Solutions, and Algorithms

Learning goals.

  • Be able to define the terms algorithm, pseudocode, and iteration
  • Be able to use pseudocode to describe the flow of an algorithm’s implementation
  • Be familiar with using iterative processes to design increasingly robust solutions
  • 10 - Warmup
  • 15 - Lecture
  • 15 - Lecture Cont.
  • 10 - Challenge 1
  • 15 - Challenge 2
  • 10 - Challenge 3
  • 5 - Closeout

Available here

Part 1 - Writing

First, spend 5 minutes writing an “algorithm” that explains how to tie your shoes. Try to be as explicit and specific as possible. Assume your reader is a human, but a very literal one.

Part 2 - Doing

Now, pair up with your neighbor. The person whose name is alphabetically first will read their algorithm step-by-step to the person whose name is alphabetically last. The person whose name is alphabetically last will attempt to tie their shoes according only to the instructions from their partner.

You can repeat instructions if needed, but don’t add any instructions beyond what you had originally written down.

Lecture - Big-Picture Strategy

  • What is an Algorithm a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.
  • Incremental solutions (linear)
  • Iterative solutions (spirals)
  • Building a full “slice”
  • “Half a product not a half-assed product”

An Iterative Process

  • Identify the big picture goal: What do you want your program to do? How will you know when you’ve succeeded?
  • Identify the interface: How do you want to interact with your program? What are its inputs and outputs?
  • Identify a small picture goal: What is the simplest case of this problem? Is there a sub-problem of even that case?
  • Plan to solve that small goal: Sketch ideas out in a notebook.
  • Write a small goal test: Identify expected inputs and outputs. Decide on a method name.
  • Implement: Write pseudocode and turn that into code.
  • Repeat: Is the whole problem solved? If not, go back to step 3.

Exercise 1 – Common Words

With a pair, answer the questions from steps 1 through 4 for the following problem. When you get to steps 3 and 4, repeat them at least 3 times for increasing levels of complexity.

I have a text document and want to know “What are the three most common words in the text?”

Extension : Let’s exclude the following: I, you, he, she, it, we, they, they, a, an.

Software Processes / Techniques – why do we care

  • Programming – what makes it hard? (Translating ideas into code? Or coming up with ideas?)
  • Perception - A good programmer is someone who solves technical problems easily
  • Reality - A good programmer is someone equipped with the tools and processes to confront challenging problems and still emerge successful
  • Problem solving challenges: What to do vs. How to do it
  • “Dumping out the toolbox” - controlling nerves and pacing yourself
  • Software development techniques are designed to manage these difficulties
  • Agile Development

Remaining Exercises

Small groups - algorithm challenges.

We’ll then break into small groups to work through this process for a few different problems.

Odds & Evens

I have a file with 100 numbers. I want to create two new files: one with all the odds and one with all the evens.

Extension : Don’t allow duplicates in the output

Palindromes

A palindrome is a word or phrase that reads the same when you reverse all of the letters.

  • Never odd or even

A palindromic number is the same concept applied to numbers:

Create a program to find the largest palindromic number that you can create by multiplying two three digit numbers together.

Lats & Longs

I have a file with 100 latitude/longitude pairs. Find the point that’s closest to the north pole.

Extension : Find the one closest to the magnetic north pole.

  • What is an algorithm? What is algorithmic thinking? Why is it necessary when working with computers?
  • How does iterative problem solving work? Why is it beneficial to us as developers?
  • What is pseudocode? How does it make programming easier? Why should we do it even if we think we’ve got a pretty sweet plan?

Lesson Search Results

Showing top 10 results.

Learn Python practically and Get Certified .

Popular Tutorials

Popular examples, reference materials, learn python interactively, dsa introduction.

  • What is an algorithm?
  • Data Structure and Types
  • Why learn DSA?
  • Asymptotic Notations
  • Master Theorem
  • Divide and Conquer Algorithm

Data Structures (I)

  • Types of Queue
  • Circular Queue
  • Priority Queue

Data Structures (II)

  • Linked List
  • Linked List Operations
  • Types of Linked List
  • Heap Data Structure
  • Fibonacci Heap
  • Decrease Key and Delete Node Operations on a Fibonacci Heap

Tree based DSA (I)

  • Tree Data Structure
  • Tree Traversal
  • Binary Tree
  • Full Binary Tree
  • Perfect Binary Tree
  • Complete Binary Tree
  • Balanced Binary Tree
  • Binary Search Tree

Tree based DSA (II)

  • Insertion in a B-tree
  • Deletion from a B-tree
  • Insertion on a B+ Tree
  • Deletion from a B+ Tree
  • Red-Black Tree
  • Red-Black Tree Insertion
  • Red-Black Tree Deletion

Graph based DSA

  • Graph Data Structure
  • Spanning Tree
  • Strongly Connected Components
  • Adjacency Matrix
  • Adjacency List
  • DFS Algorithm
  • Breadth-first Search
  • Bellman Ford's Algorithm

Sorting and Searching Algorithms

  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Counting Sort
  • Bucket Sort
  • Linear Search
  • Binary Search

Greedy Algorithms

Greedy Algorithm

  • Ford-Fulkerson Algorithm
  • Dijkstra's Algorithm
  • Kruskal's Algorithm

Prim's Algorithm

  • Huffman Coding

Dynamic Programming

  • Floyd-Warshall Algorithm
  • Longest Common Sequence

Other Algorithms

  • Backtracking Algorithm
  • Rabin-Karp Algorithm

DSA Tutorials

Merge Sort Algorithm

  • Selection Sort Algorithm

What is an Algorithm?

In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem. It takes a set of input(s) and produces the desired output. For example,

An algorithm to add two numbers:

Take two number inputs

Add numbers using the + operator

Display the result

Qualities of a Good Algorithm

  • Input and output should be defined precisely.
  • Each step in the algorithm should be clear and unambiguous.
  • Algorithms should be most effective among many different ways to solve a problem.
  • An algorithm shouldn't include computer code. Instead, the algorithm should be written in such a way that it can be used in different programming languages.

Algorithm Examples

Algorithm to add two numbers

Algorithm to find the largest among three numbers

Algorithm to find all the roots of the quadratic equation

Algorithm to find the factorial

Algorithm to check prime number

Algorithm of Fibonacci series

Algorithm 1: Add two numbers entered by the user

Algorithm 2: find the largest number among three numbers, algorithm 3: find roots of a quadratic equation ax 2 + bx + c = 0, algorithm 4: find the factorial of a number, algorithm 5: check whether a number is prime or not, algorithm 6: find the fibonacci series till the term less than 1000, table of contents.

  • Qualities of Good Algorithms
  • Add Two Numbers
  • Find Largest Number
  • Roots of Quatratic Equation
  • Find Factorial of a Number
  • Check Prime Number
  • Find Fibonacci Series

Sorry about that.

Our premium learning platform, created with over a decade of experience and thousands of feedbacks .

Learn and improve your coding skills like never before.

  • Interactive Courses
  • Certificates
  • 2000+ Challenges

Related Tutorials

DS & Algorithms

  • Computer science

a set of problem solving operations in a computer

TechTarget's guide to machine learning is a primer on this important field of computer science, further explaining what machine learning is, how to do it and how it is applied in business. You'll find information on the various types of machine learning algorithms, the challenges and best practices associated with developing and deploying ML models, and what the future holds for machine learning. Throughout the guide, there are hyperlinks to related articles that cover the topics in greater depth.

What is an algorithm.

Alexander S. Gillis

  • Alexander S. Gillis, Technical Writer and Editor

An algorithm is a procedure used for solving a problem or performing a computation. Algorithms act as an exact list of instructions that conduct specified actions step by step in either hardware- or software-based routines.

Algorithms are widely used throughout all areas of IT. In mathematics, computer programming and computer science, an algorithm usually refers to a small procedure that solves a recurrent problem. Algorithms are also used as specifications for performing data processing and play a major role in automated systems.

An algorithm could be used for sorting sets of numbers or for more complicated tasks, such as recommending user content on social media . Algorithms typically start with initial input and instructions that describe a specific computation. When the computation is executed, the process produces an output.

How do algorithms work?

Algorithms work by following a set of instructions or rules to complete a task or solve a problem. They can be expressed as natural languages , programming languages, pseudocode , flowcharts and control tables. Natural language expressions are rare, as they are more ambiguous. Programming languages are normally used for expressing algorithms executed by a computer.

This article is part of

What is machine learning? Guide, definition and examples

  • Which also includes:
  • The different types of machine learning explained
  • How to build a machine learning model in 7 steps
  • CNN vs. RNN: How are they different?

Algorithms use an initial input along with a set of instructions. The input is the initial data needed to make decisions and can be represented in the form of numbers or words. The input data gets put through a set of instructions, or computations, which can include arithmetic and decision-making processes. The output is the last step in an algorithm and is normally expressed as more data.

For example, a search algorithm takes a search query as input and runs it through a set of instructions for searching through a database for relevant items to the query. Automation software acts as another example of algorithms, as automation follows a set of rules to complete tasks. Many algorithms make up automation software, and they all work to automate a given process.

What are different types of algorithms?

There are several types of algorithms, all designed to accomplish different tasks:

  • Search engine algorithm. This algorithm takes search strings of keywords and operators as input, searches its associated database for relevant webpages and returns results.
  • Encryption algorithm. This computing algorithm transforms data according to specified actions to protect it. A symmetric key algorithm, such as the Data Encryption Standard , for example, uses the same key to encrypt and decrypt data. If the algorithm is sufficiently sophisticated, no one lacking the key can decrypt the data.
  • Greedy algorithm. This algorithm solves optimization problems by finding the locally optimal solution, hoping it is the optimal solution at the global level. However, it does not guarantee the most optimal solution.
  • Recursive algorithm. This algorithm calls itself repeatedly until it solves a problem. Recursive algorithms call themselves with a smaller value every time a recursive function is invoked.
  • Backtracking algorithm. This algorithm finds a solution to a given problem in incremental approaches and solves it one piece at a time.
  • Divide-and-conquer algorithm. This common algorithm is divided into two parts. One part divides a problem into smaller subproblems. The second part solves these problems and then combines them to produce a solution.
  • Dynamic programming algorithm. This algorithm solves problems by dividing them into subproblems. The results are then stored to be applied to future corresponding problems.
  • Brute-force algorithm. This algorithm iterates all possible solutions to a problem blindly, searching for one or more solutions to a function.
  • Sorting algorithm. Sorting algorithms are used to rearrange data structures based on a comparison operator, which is used to decide a new order for data.
  • Hashing algorithm. This algorithm takes data and converts it into a uniform message with a hashing .
  • Randomized algorithm. This algorithm reduces running times and time-based complexities. It uses random elements as part of its logic.

algorithm types

What are examples of algorithms?

Machine learning is a good example of an algorithm, as it uses multiple algorithms to predict outcomes without being explicitly programmed to do so.

Machine learning uses supervised learning or unsupervised learning . In supervised learning, data scientists supply complex algorithms with labeled training data and define the variables they want the algorithm to assess for correlations. Both the input and the output of the algorithm are specified.Unsupervised machine learning involves algorithms that train on unlabeled data and sift through it to look for patterns that can be used to group data points into subsets. Most types of deep learning , including neural networks , are unsupervised algorithms.

Machine learning used in artificial intelligence also relies on algorithms. However, machine learning-based systems may have inherent biases in the data that feeds the machine learning algorithm. This could result in systems that are untrustworthy and potentially harmful.

Although algorithms are used extensively in computer science, AI and machine learning scenarios, they're also employed frequently in everyday life.

The following are some examples of algorithms used in real life:

  • Following a recipe. Recipes provide a series of steps to achieve a particular objective, such as preparing blueberry muffins or making spaghetti sauce from scratch. Recipes aim to produce consistent results and help individuals -- regardless of their background -- create a specific dish by following detailed instructions. In this way, recipes mirror computer science algorithms, which outline steps for generating reproducible outcomes.
  • Tying shoelaces. Tying shoelaces is another example of following an algorithm. For example, there are a finite number of steps that lead to a properly tied traditional shoelace knot, which is often referred to as the "bunny rabbit" or "loop, swoop and pull" knot.
  • Facial recognition. Facial recognition is widely used in iPhone logins as well as Snapchat and Instagram filters. It works by projecting facial traits from a photo or video onto a biometrics map using an algorithm. The program then looks for a match between this map and a database of faces to confirm the user's identification. If facial recognition is used for Snapchat or Instagram filters, there is no need for searching the database because the algorithm simply builds a map of the face and applies the filter to it.
  • Traffic signals. Traffic signals use smart algorithms to manage traffic flow. These algorithms group different algorithms or movements, such as going straight or turning right, into phases, which helps ensure safety and efficiency. For example, when a motorist approaches a red light, the traffic signal is cycling through these phases. By evaluating the volume of traffic, an algorithm decides when it's safe for the vehicle to move forward.
  • Sorting documents and papers. This is a great example of how algorithms can be used for various tasks and purposes, such as sorting files alphabetically, by word count, by date, or by any other specifications. When someone arranges their personal or professional documents according to a set of instructions, they are applying algorithmic thinking to simplify the organization process by using small tasks.
  • Searching for a book in the library. Finding a library book is like following an algorithm or a step-by-step plan. For example, there are different ways to do it, such as using the library's computer system or looking for labels on the shelves that show the book's genre, subject or author. No matter which method one chooses, if it can be explained and done by others, then it can be classified as an algorithm.

Discover how AI algorithms work and provide a competitive edge for businesses. Explore the main types and learn the importance of evaluating both the benefits and risks associated with these algorithms.

Continue Reading About What is an algorithm?

  • Top 10 AI and machine learning trends
  • Why algorithmic auditing can't fully cope with AI bias in hiring
  • 12 key benefits of AI for business
  • What is AI governance and why do you need it?
  • Top 9 types of machine learning algorithms, with cheat sheet

Related Terms

In general, asynchronous -- from Greek asyn- ('not with/together') and chronos ('time') -- describes objects or events not ...

A URL (Uniform Resource Locator) is a unique identifier used to locate a resource on the internet.

File Transfer Protocol (FTP) is a network protocol for transmitting files between computers over TCP/IP connections.

Network detection and response (NDR) technology continuously scrutinizes network traffic to identify suspicious activity and ...

Identity threat detection and response (ITDR) is a collection of tools and best practices aimed at defending against cyberattacks...

Managed extended detection and response (MXDR) is an outsourced service that collects and analyzes threat data from across an ...

Data storytelling is the process of translating complex data analyses into understandable terms to inform a business decision or ...

Demand shaping is an operational supply chain management (SCM) strategy where a company uses tactics such as price incentives, ...

Data monetization is the process of measuring the economic benefit of corporate data.

Employee self-service (ESS) is a widely used human resources technology that enables employees to perform many job-related ...

Diversity, equity and inclusion is a term used to describe policies and programs that promote the representation and ...

Payroll software automates the process of paying salaried, hourly and contingent employees.

Salesforce Commerce Cloud is a cloud-based suite of products that enable e-commerce businesses to set up e-commerce sites, drive ...

Multichannel marketing refers to the practice of companies interacting with customers via multiple direct and indirect channels ...

A contact center is a central point from which organizations manage all customer interactions across various channels.

CodyCrossAnswers.com

  • A set of problem-solving operations in a computer

a set of problem solving operations in a computer

HINTS AND TIPS:

Before giving away the correct answer, here are some more hints and tips for you to guess the solution on your own!

1. The first letter of the answer is: A

2. the last letter of the answer is: m, 3. there are 3 vowels in the hidden word:.

CORRECT ANSWER :

Other Related Levels

If you successfully solved the above puzzle and are looking for other related puzzles from the same level then select any of the following:

  • 2022 film in which Tom Holland plays Nathan Drake
  • Host of Weakest Link game show after George Gray
  • American Creole and Cajun rice dish
  • Weather temperature that has a negative sign
  • President drafted the Declaration of Independence
  • 2022 Tom Holland film where he plays Nathan Drake
  • A large hairy spider
  • Wise housekeeper from To Kill a Mockingbird
  • Chinese city known as the City of Flowers
  • Process with temperature change but no heat flow
  • Triangular brand of chocolate bar
  • Mattresses that are like sleeping on a wave

If you already solved this clue and are looking for other clues from the same puzzle then head over to CodyCross Rainforest Group 1212 Puzzle 3 Answers .

  • Skip to content
  • Select language
  • Skip to search

The web browser you are using is out of date, please upgrade .

Please use a modern web browser with JavaScript enabled to visit OpenClassrooms.com

Think like a computer: the logic of programming

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Last updated on 6/15/21

Discover how computers solve problems

Have you ever wondered how a computer solves a problem?  As humans, we learn problem-solving by watching others and through trial and error.  What makes a smart car smart? What is artificial intelligence and what makes it artificial?

Computers can’t actually think, but they can perform billions of logical operations per second. These logical operations are written by us and provide the computer with the instructions needed to perform the problem-solving.  This means you need to think like a computer and translate what you need it to do into program instructions it understands.

Solving a problem like a computer

Computers are basically toddlers. You have to explain everything to them. Take the simple task of watering flowers.  What tools do you need? What steps do you need?

Pick up a watering can by the handle.

Go to the faucet.

Put the opening of the watering can under the faucet.

Turn on the faucet.

Fill the watering can with water.

Turn off the faucet.

Go to your garden.

Tilt the spout of the watering can downwards.

Pour the water on your flowers.

This looks deceptively simple.  However, if you forget to tell your toddler...er...computer to pick up the watering can by the handle, it may try to pick it up by the spout.  If you don’t tell it to turn the faucet on, it will just sit there, staring at it. And if you don’t tell it to turn it off, it might just let the water run. 🚰 You can see where this is going.

Toddler watering flowers

Computers can’t make assumptions or guess what you want .  If you tell a computer to dust the furniture, it will actually put dust on your furniture, instead of removing it!  It can’t read context clues, so it will take all of your instructions literally. This is why it’s important to think through all the logical gaps in your instructions!

Try it out for yourself!

Write out the steps to making a cup of coffee or tea.  Write down everything that needs to be done. If you use milk or cream, don’t forget to say how to find it!  Once you’re done, test your instructions out on a friend. Tell them to follow the directions exactly.  Have you missed anything?

Computers can solve problems by performing billions of operations per second .

A programmer’s job is to find solutions . They do this by breaking down problems into easy-to-follow steps for a computer.

Programming languages allow people to communicate with computers.

Computers are literal and do exactly what you tell them to.

Example of certificate of achievement

Only Premium members can download videos from our courses. However, you can watch them online for free.

Just another Duke WordPress Sites site

Algorithms in Real Life: What is an Algorithm?

They are everywhere. 

From social media apps and search engines to video streaming sites and dating apps, algorithms are everywhere in our modern, technology-driven world. 

But what exactly is an algorithm? 

How do they work? 

Who makes them? 

And should we be worried about them? 

Let’s figure out. 

With a quick Google search, we see that an algorithm is defined as “a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.” This might sound like a riddle to you. There are so many definitions on the internet that do not clearly explain what algorithms actually do. I’m here to help!

a set of problem solving operations in a computer

A non-internet based example of an algorithm is a cookbook recipe. A recipe provides a set of instructions to specify how you should put together several ingredients to get a product (eg. sandwich) on the other end. In the peanut butter and jelly sandwich example above, we are given 2 slices of bread, 1 tablespoon of peanut butter, and 2 tablespoons of strawberry jam as inputs to our algorithm. The algorithm we use to make the sandwich might include the following procedures: 

  • Gather Your Ingredients for the Sandwich
  • Pull Out Two Slices of Bread
  • Open Peanut Butter and Jelly
  • Spread the Peanut Butter Onto One Slice of Bread
  • Spread the Jelly Onto the Other Slice of Bread
  • Combine the Two Slices

After completing the instructions specified by the algorithm, we are able to accurately produce our output  ― a delicious peanut butter and jelly sandwich! 

Algorithms in Computer Science

An algorithm in Computer Science does effectively the same thing ― it is a set of instructions that enables a computer program to put together different input sources and output a result. 

a set of problem solving operations in a computer

While a programmer implements code to specify the algorithm for recommending new YouTube videos or which post you see first on your Facebook feed, users are usually unaware of how an algorithm is designed. As a user, you can treat an algorithm as a “black box” – you provide valid input information and wait to see the magic happen. When we use Google Maps to find the fastest route to a destination, we don’t need to worry about what computations we need to make to locate the shortest path (thank god!). We simply provide the algorithm with relevant input information such as our starting point, destination, and mode of travel and the algorithm automatically generates the best path for us. This principle of removing unnecessary details (e.g. how the shortest path is computed) to boost user experience is a recurring concept in Computer Science known as “abstraction”. 

a set of problem solving operations in a computer

Correctness

How do we know if an algorithm is well-designed? We can start with analyzing its “correctness”. It is likely that you have experienced the frustrations of dealing with a poorly-designed algorithm yourself. When I was child, my parents purchased a new car GPS navigator. On a road trip, the GPS incorrectly led us to a rural farm and instructed us to drive into a field of crops. Luckily, we quickly disregarded the misguided directions and eventually found our way back on track. In this case, the GPS algorithm was “incorrect”. In other words, it failed to produce the correct output we were looking for ― a feasible path to our final destination. In certain high-stakes situations, incorrect algorithms can even yield life-or-death consequences. On March 19, 2018, an Uber self-driving car running in autonomous mode hit and killed a woman walking on a poorly lit road. According to Uber, the algorithm incorrectly classified the women as “unknown object”, then “vehicle”, and then “bicycle” during the brief encounter. It is this indecisiveness that led to a very late action (stopping the car), which eventually caused the tragedy. Algorithms are useful when they are correct, helping us automate tedious tasks, find valuable information, and perform complex procedures. On the other hand, incorrect algorithms do more harm than good, from wasting time to even taking lives. 

a set of problem solving operations in a computer

We can also analyze an algorithm by evaluating its “efficiency”. Going back to the Google Map example: What if a search for the fastest route to a nearby destination takes an hour? If driving to the destination only takes 15 minutes on average, there is no point in making the search before traveling there. Even if we choose a slower route from our memory, we would still arrive at the destination faster than waiting for the app recommendation result and taking the fastest route. This shows how even if an algorithm is correct, it is ultimately unhelpful if it takes too much time to run. 

a set of problem solving operations in a computer

Algorithms are not as difficult to understand as many people think ― they show up in many facets of our daily lives and help us better utilize the resources around us. 

' src=

July 12, 2021 at 2:58 pm

Your comment about the consequences of algorithms is an interesting but scary one. It really has me evaluating how much we rely on technology and how much that reliance is based on a potentially false assumption that the technology will be correct all the time. It’s interesting that we’ve learned to trust new technologies more than ourselves even though we don’t necessarily understand (at least in my case) what’s going on behind the scenes.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

© 2024 Teaching & Tech (Eric)

Theme by Anders Noren — Up ↑

is powered by WordPress. Read the Sites@Duke Express and , or .

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Computer Program vs. Algorithm

It's said that a program include algorithms, however if we refer to their definition, an algorithm is a sequence of instructions written to perform a specified task and a computer program is also a sequence of instructions to perform a (some) tasks with computer.

Then what makes a program different from an algorithm? is it a type of algorithm too?

In fact, I look for formal definitions for an algorithm and a computer program so I can distinguish them from each other or identify algorithms within a program.

Update :I have noticed in Wikipedia by an informal definition (at least syntactically) any program is an algorithm.

An informal definition could be "a set of rules that precisely defines a sequence of operations." which would include all computer programs , including programs that do not perform numeric calculations. Generally, a program is only an algorithm if it stops eventually .
  • terminology
  • programming-languages

Ahmad's user avatar

10 Answers 10

I'm going to give the same answer as I gave the previous time this question came up.

First, understand that there is no good formal definition of "algorithm" at the time of writing. The key word here is "formal".

However, there are smart people working on it.

What we know is that whatever an "algorithm" is, it sits somewhere between "mathematical function" and "computer program".

A mathematical function is formal notion of a mapping from inputs to outputs. So, for example, "sort" is a mapping between a sequence of orderable items and a sequence of orderable items of the same type, which maps each sequence to its ordered sequence. This function could be implemented using different algorithms (e.g. merge sort, heap sort). Each algorithm, in turn, could be implemented using different programs (even given the same programming language).

So the best handle that we have on what an "algorithm" is, is that it's some kind of equivalence class on programs, where two programs are equivalent if they do "essentially the same thing". Any two programs which implement the same algorithm must compute the same function, but the converse is not true.

Similarly, there is an equivalence class between algorithms, where two algorithms are equivalent if they compute the same mathematical function.

The hard part in all this is trying to capture what we mean by "essentially the same thing".

There are some obvious things that we should include. For example, two programs are essentially the same if they differ only by variable renamings. Most models of programming languages have native notions of "equivalence" (e.g. beta reduction and eta conversion in lambda calculus), so we should throw those in too.

Whatever equivalence relation we pick, this gives us some structure. Algorithms form a category by virtue of the fact that they are the quotient category of programs. Some interesting equivalence relations are known to give rise to interesting categorical structures; for example, the category of primitive recursive algorithms is a universal object in the category of categories. Whenever you see interesting structure like that, you know that this line of enquiry will probably be useful.

Pseudonym's user avatar

  • $\begingroup$ Thank you for your precise answer, just another question. If we consider any program, regardless what it does, they still get some inputs and follow some instructions, and give some results as they are executed. They even may don't solve any problem (as we call), but it is still a mapping. could they be known algorithm, I mean any program? $\endgroup$ –  Ahmad Commented Feb 16, 2015 at 5:55
  • 1 $\begingroup$ If I'm reading you correctly, you're asking if a formal definition of an "algorithm" should or should not carry the proviso that it must be "useful". I would say "no", if only because it's impossible to formalise that notion. $\endgroup$ –  Pseudonym ♦ Commented Feb 16, 2015 at 6:30
  • $\begingroup$ sorry! my English is not well, then you say "no" to what? you admit that it's impossible to formalise the usefulness of a program, and just by definition, any program is an algorithm? or you say it's necessary that we consider usefulness beside the algorithm? $\endgroup$ –  Ahmad Commented Feb 16, 2015 at 16:57
  • 1 $\begingroup$ I don't think that a formal definition of an "algorithm" should require it to be useful, because "useful" can't be formally defined. $\endgroup$ –  Pseudonym ♦ Commented Feb 16, 2015 at 22:20
  • $\begingroup$ Your answer is the most useful in this thread +1. I believe by "essentially the same thing", you mean "semantically equivalent". Also, I think all programs are essentially algorithms (as OP says), since all programs are implementations which map some input to some output, even if this mapping be implicit. As you stated, it all depends on the perspective. $\endgroup$ –  doubleOrt Commented Jun 20, 2018 at 12:56

Ultimately, the difference is one of perspective. A program is a program: a sequence of statements in some language, perhaps a programming language or machine-level instructions. Algorithms are usually described at a higher level than machine instructions or programming language statements but just how high a level is rather flexible. For example, in some circumstances, "Sort the array, then look at the $k$th element" is a perfectly good description of an algorithm for finding the $k$th largest object in an array; in other circumstances, you might want to specify much more detail about how the sorting takes place.

As you say, an algorithm is something like "a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer." So, literally speaking, every program is an algorithm. Usually, though, we speak of programs implementing algorithms. Usually, when describing an algorithm, we avoid the low-level detail of exactly how things are implemented, assuming that a competent programmer would be able to implement it in the langauge of their choosing.

David Richerby's user avatar

  • $\begingroup$ I think the precise of algorithm is related to mathematics concept, lambda-calculus or Turing machine, still don't know what is that abstraction language? mathematics or a natural language with many fuzzy statements $\endgroup$ –  Ahmad Commented Feb 15, 2015 at 15:51
  • 8 $\begingroup$ @Ahmad Algorithm is an informal concept. It has no formal definition. In a sense, it's like a mathematical proof, which is different from a formal proof in a formal proof system. We believe that informal proofs can be "fleshed out" to formal proofs in any chosen (strong enough) formal proof system, just as any algorithm can be fully implemented in any (Turing-complete) programming language. $\endgroup$ –  Yuval Filmus Commented Feb 15, 2015 at 19:46

Algorithms in the Turing-complete mindset are usually specified by input and output. Real programs do more; they

  • communicate with the user,
  • communicate with other machines,
  • react to the environment,
  • do not terminate and are still useful,

and more. These things are usually not considered in algorithms or theory of computation, but are essential for most programs.

Raphael's user avatar

  • $\begingroup$ This is a very good point. But do you mean something like "usually specified as a means to map input to output"? Just specifying the input and output isn't enough: e.g., mergesort and quicksort produce the same output from any input but aren't considered to be the same algorithm. $\endgroup$ –  David Richerby Commented Feb 16, 2015 at 8:47
  • $\begingroup$ @DavidRicherby I was thinking of specification in the PL sense; we don't specify anything else, so algorithms may not do anything else. Of course, we have to give more than the specification to describe a concrete algorithm. $\endgroup$ –  Raphael Commented Feb 16, 2015 at 8:59
  • $\begingroup$ Good points, but if we admit that in the end any program is an algorithm, I don't know how those matters you addressed are measured about an algorithm. Maybe an AI topic?! $\endgroup$ –  Ahmad Commented Feb 16, 2015 at 16:59
  • $\begingroup$ Who would admit that, and why? And what do you mean by measure here? (And I certainly don't see the AI angle here.) $\endgroup$ –  Raphael Commented Feb 16, 2015 at 21:21
  • $\begingroup$ @Raphael I may admit it (by looking at the syntax, all programs look similar, they are sequences of instructions, or mapping of input to output), I just don't know how other features of a program (those you addressed) can be extracted from that definition. for example the difference between quick-sort and MATLAB or Windows Media Player!! $\endgroup$ –  Ahmad Commented Feb 18, 2015 at 7:04

An algorithm is a concept or idea. It is a formal approach for solving a problem. Algorithms can be expressed, or implemented, in a variety of programming language (usually, almost any language can implement any algorithm). For some examples you should read through the Sorting Algorithms in Wikipedia.

A computer program is a specific sequence of instructions in a specific programming language. A program may contain the implementation of many algorithms. Excel is a program, but it's sorting capabilities are the manifestation of an algorithm.

Alex Fitzpatrick's user avatar

An algorithm is a systematic approach to solving a specific problem.

A program is a set of instructions for a computer to follow.

A program therefore does not even need to solve a problem. I'm sure we can all think of several programs that have caused more problems than they've solved. A program can be an implementation of many algorithms, or an algorithm can be implemented by patching together many programs. A program can even contain no algorithms. For example, the empty program which simply exits, or perhaps even a Hello World, could be considered a program with no algorithm.

Since an algorithm solves a specific problem, it is focused on a specific whole concept. An algorithm therefore provides abstract steps for processing one set of related information into a different set of derived information. A program does not require its constituents to be at all conceptually related. For example, a program can have an easter egg, but a thing properly called an algorithm should not. You can have a virus or trojan lurking in a program, but not in an algorithm. The closest an algorithm can get to this would be something like a backdoor in an encryption algorithm, where the planned flaw is part of the information relationship established by the algorithm.

And lastly, a program, as it is short for a computer program, tautologically requires a computer. An algorithm does not. If I systematically separate the shirts, pants, and socks from my laundry before putting them away, this is an algorithm. It deals with related inputs and outputs, can be described in a flow chart, and has calculable consequences in terms of efficiency (for example, the number of clothing pieces which must be compared to find matching socks).

Ryan Colyer's user avatar

Here is a couple of ways to draw the line between an algorithm and a program:

Meaningful Purpose

Programs are written with a purpose and represent an attempt to achieve a goal. Algorithms may be viewed as tools to achieve that goal.

E.g. a screwdriver is an algorithm to modify the state of a screw but the screwdriver itself does not hold a purpose to do that. The purpose is in the head of the screwdriver operator who holds the program like putting up shelves.

Business logic

This point strongly relates to the purpose of a program. Since programs have purposes they inevitably have bits of real world in them like specific dates, measurements, technologies, names etc.

Algorithms on the other hand contain neither business logic nor bits of real world and instead of operating on specific values operate on variables.

E.g. in this sense you can compare a mathematical function like f(x) = x^2 which is abstract and operates on variables to a cooking recipe which contains precise values (at least one for reference).

This point strongly relates to the business logic of a program. An agent (like a web browser user) consumes the result of a program not the result of an algorithm.

E.g. the consumer of a cooking recipe consumes the cake not the result of whipping cream or heating oven.

Robert Mugattarov's user avatar

  • $\begingroup$ Perhaps it would be better to say that the screwdriver doesn't have the intent to turn screws? In everyday English, we would certainly say that a screwdriver does have the purpose of turning screws: turning screws is the exact thing it was designed to do. $\endgroup$ –  David Richerby Commented Jan 11, 2017 at 14:26
  • $\begingroup$ Also, I'm not sure what you mean by "business logic" (many programs have nothing to do with business) or by saying that an algorithm "contains neither business logic nor bits of the real world". For example, I could perfectly well phrase a shortest-path algorithm in terms of towns and roads rather than vertices and edges. Doesn't the algorithm then "contain... bits of the real world"? $\endgroup$ –  David Richerby Commented Jan 11, 2017 at 14:28
  • $\begingroup$ @DavidRicherby, you are right, my phrasing is ambiguous. What I meant is a meaningful purpose. Turning screws to turn screws is pointless just as well as sorting an array which is never used. By business logic I mean all program logic except for utility logic and technology stack boilerplate i.e. all logic that actually implements the purpose of the program i.e. the business logic of baking a cake is mixing ingredients and baking and does not include learning to mix or bake (which is reused utility logic in this case). $\endgroup$ –  Robert Mugattarov Commented Jan 11, 2017 at 16:08
  • $\begingroup$ @DavidRicherby, as for bits of real world , I mean actualization i.e. a program unlike an algorithm has to communicate in some way with the physical world. An algorithm, on the other hand, can be a purely mathematical concept. $\endgroup$ –  Robert Mugattarov Commented Jan 11, 2017 at 16:22
An algorithm is a self-contained step-by-step set of operations to be performed to solve a specific problem or a class of problems. A computer program is a sequence of instructions that comply the rules of a specific programming language , written to perform a specified task with a computer.

Algorithms are general and have to be translated into a specific programming language (implemented).

Community's user avatar

  • 1 $\begingroup$ But the whole point of the question is that a program (either its source code or the compiled binary) is "a self-contained step-by-step set of operations to be performed to solve a specific problem or class of problems." $\endgroup$ –  David Richerby Commented Feb 15, 2015 at 16:24
  • $\begingroup$ But it isn't. A program is not those operations, but an implementation of them: something that executes them in a particular context. E.g. the Unix sort utility is not a sorting algorithm, it uses a sorting algorithm. $\endgroup$ –  reinierpost Commented Jan 11, 2017 at 20:52

An algorithm is expressing our idea or solution for specific problem in step by step approach.it is only problem solving and human understandable approach not for computer system

Program is step by step instructions which implemented for solving problem by computer system .it must be understandable by not only programmer also computer.

Pooja Thanekar's user avatar

  • $\begingroup$ Welcome to Computer Science Stack Exchange. Please read cs.stackexchange.com/tour.if you have not yet done so. $\endgroup$ –  babou Commented Jul 23, 2015 at 12:44

The other answers here, I think, miss an important point. The definition of 'algorithm' which I was taught included the requirement that the procedure halts on all inputs . Naturally that makes 'program' a broader class of procedures than 'algorithm', since some programs halt on all inputs and others do not.

PMar's user avatar

  • 2 $\begingroup$ This is not universal. The definition I was taught didn't include that requirement. $\endgroup$ –  reinierpost Commented Jan 11, 2017 at 20:47

I am pretty sure that other answers are good enough to take the lead but here's how I see the difference between an algorithm and program

An algorithm consists of simply the steps (machine independent) needed to be followed in some order to solve a problem.

A program is an instruction set for a specific type of machine to put an algorithm to practice .

For example.

Let's say you have an algorithm that has a step for reaching to a particular place before doing some other step.Now how this step of reaching will be carried out is not exactly defined.You may choose to walk or run or take a bus for doing it but that depends on how you choose to implement it (which is your program).

You can say that an algorithm is an abstraction of a program i.e. missing the exact details but lays out a plan to do something.

Romantic Electron's user avatar

  • $\begingroup$ A programme is not an instruction set but a structured set of instructions. “Instruction set” normally refers to the things that a (physical or virtual) processor can do, and can be considered as a programming language for that processor, but usually one with no structuring element other than conditional jumps. $\endgroup$ –  PJTraill Commented Jan 6, 2023 at 17:29

Not the answer you're looking for? Browse other questions tagged algorithms terminology programming-languages or ask your own question .

  • Featured on Meta
  • Site maintenance - Mon, Sept 16 2024, 21:00 UTC to Tue, Sept 17 2024, 2:00...
  • User activation: Learnings and opportunities
  • Join Stack Overflow’s CEO and me for the first Stack IRL Community Event in...

Hot Network Questions

  • how to use отметить to mean "to sign out"
  • Can Cantrip Connection be used with innate cantrips?
  • PCB layout guidelines Magnetic Sensor
  • How Can We Use the Native Matrix Block Copy Feature in Craft CMS 5?
  • BASH - Find file with regex - Non-recursively delete number-only filenames in directory
  • Paying a parking fine when I don't trust the recipient
  • Gridded plane colouring problem. Can a 2x2 black square be created on a white gridded plane using 3x3 and 4x4 "stamps" that invert the grid colour?
  • Can I repeat link labels several times on a web page without hurting SEO by using meta attributes?
  • Father and Son treasure hunters that ends with finding one last shipwreck (childrens/young adult)
  • Can a V22 Osprey operate with only one propeller?
  • How would platypus evolve some sort of digestive acid?
  • How can I verify integrity of the document types?
  • How do you ensure that calendar invites won't be moved out of your inbox when your rules are executed?
  • NSolve uses all CPU resources
  • What about the other 35 children who were born in the same manner in The Umbrella Academy. Do we hear what happened to them in the comic or TV Show?
  • How can I support a closet rod where there's no shelf?
  • How can I analyze the anatomy of a humanoid species to create sounds for their language?
  • The quest for a Wiki-less Game
  • How do elected politicians get away with not giving straight answers?
  • How is switching of measurement ranges in instruments, like oscilloscopes, realized nowadays?
  • Is Produce Flame a spell that the caster casts upon themself?
  • Would it be illegal for Companies House to require a response to a letter on registration?
  • What are the pros and cons of the classic portfolio by Wealthfront?
  • Is it possible for one wing to stall due to icing while the other wing doesn't ice?

a set of problem solving operations in a computer

  • More from M-W
  • To save this word, you'll need to log in. Log In

Definition of algorithm

Did you know.

What Does algorithm Mean?

The current term of choice for a problem-solving procedure, algorithm , is commonly used nowadays for the set of rules a machine (and especially a computer) follows to achieve a particular goal. It does not always apply to computer-mediated activity, however. The term may as accurately be used of the steps followed in making a pizza or solving a Rubik’s Cube as for computer-powered data analysis.

Algorithm is often paired with words specifying the activity for which a set of rules have been designed. A search algorithm , for example, is a procedure that determines what kind of information is retrieved from a large mass of data. An encryption algorithm is a set of rules by which information or messages are encoded so that unauthorized persons cannot read them.

Though first attested in the early 20th century (and, until recently, used strictly as a term of mathematics and computing), algorithm has a surprisingly deep history. It was formed from algorism “the system of Arabic numerals,” a word that goes back to Middle English and ultimately stems from the name of a 9th-century Persian mathematician, abu-Jaʽfar Mohammed ibn-Mūsa al-Khuwārizmi, who did important work in the fields of algebra and numeric systems.

Examples of algorithm in a Sentence

These examples are programmatically compiled from various online sources to illustrate current usage of the word 'algorithm.' Any opinions expressed in the examples do not represent those of Merriam-Webster or its editors. Send us feedback about these examples.

Word History

alteration of Middle English algorisme , from Old French & Medieval Latin; Old French, from Medieval Latin algorismus , from Arabic al-khuwārizmi , from al-Khwārizmī flourished a.d. 825 Islamic mathematician

1926, in the meaning defined above

Phrases Containing algorithm

  • Euclidean algorithm

Articles Related to algorithm

cat using abacus for arithmetic

We Told You There'd Be No Math. (We...

We Told You There'd Be No Math. (We Lied.)

Grab your protractor.

Dictionary Entries Near algorithm

algorithmics

Cite this Entry

“Algorithm.” Merriam-Webster.com Dictionary , Merriam-Webster, https://www.merriam-webster.com/dictionary/algorithm. Accessed 12 Sep. 2024.

Kids Definition

Kids definition of algorithm, more from merriam-webster on algorithm.

Nglish: Translation of algorithm for Spanish Speakers

Britannica English: Translation of algorithm for Arabic Speakers

Britannica.com: Encyclopedia article about algorithm

Subscribe to America's largest dictionary and get thousands more definitions and advanced search—ad free!

Play Quordle: Guess all four words in a limited number of tries.  Each of your guesses must be a real 5-letter word.

Can you solve 4 words at once?

Word of the day.

See Definitions and Examples »

Get Word of the Day daily email!

Popular in Grammar & Usage

Plural and possessive names: a guide, 31 useful rhetorical devices, more commonly misspelled words, absent letters that are heard anyway, how to use accents and diacritical marks, popular in wordplay, 8 words for lesser-known musical instruments, it's a scorcher words for the summer heat, 7 shakespearean insults to make life more interesting, 10 words from taylor swift songs (merriam's version), 9 superb owl words, games & quizzes.

Play Blossom: Solve today's spelling word game by finding as many words as you can using just 7 letters. Longer words score more points.

 alt=

  • Undergraduate
  • Postdoctoral Programs
  • Future Engineers
  • Professional Education
  • Open Access
  • Global Experiences
  • Student Activities
  • Leadership Development
  • Graduate Student Fellowships
  • Aeronautics and Astronautics
  • Biological Engineering
  • Chemical Engineering
  • Civil and Environmental Engineering
  • Electrical Engineering and Computer Science
  • Institute for Medical Engineering and Science
  • Materials Science and Engineering
  • Mechanical Engineering
  • Nuclear Science and Engineering
  • Industry Collaborations
  • Engineering in Action
  • In The News
  • Video Features
  • Newsletter: The Infinite
  • Ask an Engineer
  • Facts and Figures
  • Diversity, Equity & Inclusion
  • Staff Spotlights
  • Commencement 2024

Ask An Engineer

How do computers perform complex mathematical operations?

Related Questions

  • Why is speed at sea measured in knots?
  • Can a computer generate a truly random number?
  • When will AI be smart enough to outsmart people?
  • How were we able to navigate from the Earth to the Moon with such precision?
  • How did people in the olden days create software without any programming software?
  • Is computer software always a step ahead of hardware?
  • Is chaos an actual state, or just a name for rules we haven’t discovered yet?
  • Can we use artificial intelligence to generate new ideas?
  • How can I tell if a certain tree is big enough to support a 30-foot zip line?
  • Does the outside edge of a ceiling fan blade move faster than the inside edge?

How do computers perform complex mathematical operations?

One small step at a time (but very, very quickly)…

Computers perform dazzlingly complex tasks, but the microprocessor chips inside them are only capable of performing very basic mathematical operations, such as adding and comparing binary numbers. Utilizing this limited toolset to perform calculus and other advanced mathematical operations was a signal achievement of the early days of electronic computing. Institute professor and former dean of engineering Joel Moses was part of that revolutionary effort, and explains that the solution lay in breaking down large and complex problems into smaller and simpler ones.

Complex math requires the handling of two types of operations:  numerical  ones that involve specific numerical values, and  symbolic ones, such as those in algebra and calculus, that involve symbols like “x” and “y.”

Moses notes that numerical operations can be broken into addition, subtraction, multiplication, and division, which are bread-and-butter tasks for a microprocessor. To accommodate a wider range of numerical values without overwhelming memory and processing resources, computers use the floating-point system, replacing common numbers (say, 1,300,000) with floating-point values (say, 1.3 x 106). This approach usually produces only an approximation of the result, but with some care it renders values extremely close to the “correct” answer. (One notable exception: some Intel Pentium chips in the early 1990s had a floating-point bug that in rare cases caused incorrect calculations.)

Symbolic operations are a bigger challenge. “The first problem,” explains Moses, “is how to represent symbols using only the 0s and 1s available in a binary computer. This is done with coding, where ‘x’ is represented by one number and ‘y’ by another.” The computer hardware and software understands these as codes, rather than numerical values. More complex expressions can be represented via a decomposition of expressions into simpler parts, which are connected by pointers in the computer’s memory. This allows representation and processing of expressions such as “x + 2y.”

For example, a differentiation can be reduced into steps that differentiate simpler expressions. The results of such differentiated expressions can be represented as sums, products, constants, and variables. The ultimate result is a procedure that incorporates a complete differentiation algorithm but uses only computer-friendly numbers and functions. Other operations, such as symbolic integration, can be even more complex, but the basic concept is usually the same: reduce the complex problem into simpler ones, and compute.

While these procedures can be lengthy and sometimes time-consuming, today’s microprocessors are so powerful that they make short work of them by performing billions operations per second.

More information on this topic is available in the textbook  Structure and Interpretation of Computer Programs,  available online from MIT Press.

Posted: November 16, 2010

 alt=

  • Data Science
  • Data Analysis
  • Data Visualization
  • Machine Learning
  • Deep Learning
  • Computer Vision
  • Artificial Intelligence
  • AI ML DS Interview Series
  • AI ML DS Projects series
  • Data Engineering
  • Web Scrapping

Water Jug Problem in AI

The Water Jug Problem is a classic puzzle in artificial intelligence (AI) that involves using two jugs with different capacities to measure a specific amount of water. It is a popular problem to teach problem-solving techniques in AI, particularly when introducing search algorithms . The Water Jug Problem highlights the application of AI to real-world puzzles by breaking down a complex problem into a series of states and transitions that a machine can solve using an intelligent algorithm.

In this article, we’ll explore the Water Jug Problem, its significance in AI, and how search algorithms like Breadth-First Search (BFS) and Depth-First Search (DFS) can be used to solve it.

Table of Content

Problem Description: Water Jug Problem

Significance in ai, state space representation, search algorithms to solve the water jug problem, 1. breadth-first search (bfs), 2. depth-first search (dfs).

  • Solving the Water Jug Problem Using State Space Representation and Breadth-First Search (BFS)

Applications of the Water Jug Problem

Faqs: water jug problem in ai.

The Water Jug Problem typically involves two jugs with different capacities. The objective is to measure a specific quantity of water by performing operations like filling a jug, emptying a jug, or transferring water between the two jugs. The problem can be stated as follows:

  • You are given two jugs, one with a capacity of X liters and the other with a capacity of Y liters.
  • You need to measure exactly Z liters of water using these two jugs.
  • Fill one of the jugs.
  • Empty one of the jugs.
  • Pour water from one jug into another until one jug is either full or empty.

The Water Jug Problem is an excellent example to introduce key AI concepts such as state space , search algorithms , and heuristics . Each operation in the problem represents a transition between states, where each state is a unique configuration of water levels in the two jugs. The solution to the problem involves finding the sequence of actions that leads to the desired amount of water.

This problem is a simplified version of real-world situations where limited resources and constraints must be managed. For example, it can be compared to industrial processes where tanks of varying capacities must distribute fluids efficiently.

In AI terms, the Water Jug Problem can be described using a state space representation, where:

  • Each state is represented by a tuple (a, b) , where a is the amount of water in the first jug and b is the amount of water in the second jug.
  • The initial state is (0, 0) , meaning both jugs are empty.
  • The goal state is any configuration (a, b) where a or b equals the desired amount Z .
  • Transitions between states occur when one of the allowed operations is performed.

To solve the Water Jug Problem using AI techniques, we can apply search algorithms like Breadth-First Search (BFS) and Depth-First Search (DFS) . These algorithms systematically explore the state space to find the optimal sequence of operations that leads to the goal state.

  • BFS explores all possible states level by level, ensuring that the shortest path (fewest operations) is found. It is particularly useful for the Water Jug Problem as it guarantees finding the optimal solution.
  • BFS starts from the initial state (0, 0) and explores all neighboring states, then their neighbors, and so on until the goal state is found.
  • DFS explores each path from the initial state as deeply as possible before backtracking. While DFS can find a solution, it does not guarantee the optimal one and may result in exploring longer paths unnecessarily.
  • DFS works well for smaller problems but may struggle with larger state spaces due to its depth-first nature.

Solving the Water Jug Problem Using State Space Representation and Depth-First Search (DFS)

For instance, given two jugs with capacities of 3 liters and 5 liters, and a goal of measuring 4 liters, the search for a solution begins from the initial state and moves through various possible states by filling, emptying, and pouring the water between the two jugs.

In this solution, we use a Depth-First Search (DFS) algorithm to solve the Water Jug Problem , where the jugs have capacities of 3 liters and 5 liters, and the goal is to measure 4 liters of water. In DFS, the algorithm explores deeper paths first before backtracking if the solution is not found.

Defining the State Space

We represent each state as a pair (x, y) where:

  • x is the amount of water in the 3-liter jug.
  • y is the amount of water in the 5-liter jug.

The initial state is (0, 0) because both jugs start empty, and the goal is to reach any state where either jug contains exactly 4 liters of water.

Operations in State Space

The following operations define the possible transitions from one state to another:

  • Fill the 3-liter jug : Move to (3, y) .
  • Fill the 5-liter jug : Move to (x, 5) .
  • Empty the 3-liter jug : Move to (0, y) .
  • Empty the 5-liter jug : Move to (x, 0) .
  • Pour water from the 3-liter jug into the 5-liter jug : Move to (max(0, x - (5 - y)), min(5, x + y)) .
  • Pour water from the 5-liter jug into the 3-liter jug : Move to (min(3, x + y), max(0, y - (3 - x))) .

Python Implementation: Solving Water Jug Problem Using Depth First Search

dfs

This code visualizes the DFS solution path as a directed graph, where each node represents a state (amount of water in each jug), and each edge represents a transition between states based on the operations (fill, empty, or pour). The blue edges show the path DFS takes to reach the solution.

Although the Water Jug Problem itself is a theoretical puzzle, its principles apply to real-world problems, such as:

  • Managing resources under constraints , like liquid distribution in a refinery or industrial process.
  • Puzzle-solving AI : Similar problems can be found in robotics, where robots must handle tasks with limited resources and defined constraints.
  • Game theory : The problem also serves as a model for certain types of decision-making tasks in game theory and optimization.

The Water Jug Problem is a simple yet powerful example of how AI can be applied to solve puzzles using search algorithms. By representing the problem as a state space and exploring the transitions between states, AI can find the optimal solution through search techniques like BFS and DFS. This problem not only teaches fundamental concepts of AI but also provides insights into how AI can be used to solve more complex resource management issues in real-world scenarios.

What is the Water Jug Problem in AI?

The Water Jug Problem is a puzzle where two jugs with different capacities are used to measure a specific amount of water, using operations like filling, emptying, and pouring water between the jugs.

What algorithms are used to solve the Water Jug Problem?

Common algorithms used to solve the Water Jug Problem are Breadth-First Search (BFS) and Depth-First Search (DFS) , which explore the state space of possible water configurations.

Why is the Water Jug Problem important in AI?

The Water Jug Problem is important in AI because it introduces fundamental concepts such as state space , search algorithms , and problem-solving under constraints , which are crucial for solving real-world AI problems.

How can the Water Jug Problem be applied in real life?

The principles of the Water Jug Problem can be applied in resource management scenarios, like distributing liquids in industrial processes, or in robotics and game theory for decision-making tasks.

Please Login to comment...

Similar reads.

  • AI-ML-DS With Python
  • 105 Funny Things to Do to Make Someone Laugh
  • Best PS5 SSDs in 2024: Top Picks for Expanding Your Storage
  • Best Nintendo Switch Controllers in 2024
  • Xbox Game Pass Ultimate: Features, Benefits, and Pricing in 2024
  • #geekstreak2024 – 21 Days POTD Challenge Powered By Deutsche Bank

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

IMAGES

  1. algorithm for problem solving in computer

    a set of problem solving operations in a computer

  2. 6 Ways to Improve Your Programming Problem Solving

    a set of problem solving operations in a computer

  3. Problem Solving Concepts

    a set of problem solving operations in a computer

  4. Problem Solving Using Computer

    a set of problem solving operations in a computer

  5. Problem Solving In Programming

    a set of problem solving operations in a computer

  6. Overview problem Solving Computer Programming What is Computer

    a set of problem solving operations in a computer

VIDEO

  1. Lec 7

  2. Job Sequencing Explained

  3. 8.1.2 BASIC DATA TYPES

  4. Inventory Theory Simplified

  5. Operation on Sets Concept

  6. Basic Operations of Computer, Class: 9th, Computer Science, Chapter: 1 by Leaders Knowledge Hub

COMMENTS

  1. What is Algorithm

    The word Algorithm means " A set of finite rules or instructions to be followed in calculations or other problem-solving operations ". Or. " A procedure for solving a mathematical problem in a finite number of steps that frequently involves recursive operations". Recommended Problem. Dr. Zora's Algorithm.

  2. Algorithm

    Flowchart of using successive subtractions to find the greatest common divisor of number r and s. In mathematics and computer science, an algorithm (/ ˈ æ l ɡ ə r ɪ ð əm / ⓘ) is a finite sequence of mathematically rigorous instructions, typically used to solve a class of specific problems or to perform a computation. [1] Algorithms are used as specifications for performing ...

  3. What Is an Algorithm?

    An algorithm is a sequence of instructions that a computer must perform to solve a well-defined problem. It essentially defines what the computer needs to do and how to do it. Algorithms can instruct a computer how to perform a calculation, process data, or make a decision. The best way to understand an algorithm is to think of it as a recipe ...

  4. Understanding Algorithms: The Key to Problem-Solving Mastery

    Algorithms are at the heart of various applications, from simple calculations to sophisticated machine learning models and complex data analysis. Understanding algorithms and their inner workings is crucial for anyone interested in computer science. They serve as the backbone of software development, powering the creation of innovative ...

  5. The Role of Algorithms in Computing

    1.Data processing: Algorithms are used to process and analyze large amounts of data, such as sorting and searching algorithms. 2.Problem solving: Algorithms are used to solve computational problems, such as mathematical problems, optimization problems, and decision-making problems. 3.Computer graphics: Algorithms are used to create and process ...

  6. What is an Algorithm? Algorithm Definition for Computer Science Beginners

    If you're a student and want to study computer science, or you're learning to code, then there's a chance you've heard of algorithms. Simply put, an algorithm is a set of instructions that performs a particular action. Contrary to popular belief, an algorithm is not some piece of code that requires extremely advanced knowledge in order ...

  7. What Is An Algorithm? [Everything to know]

    An algorithm is a set of commands that must be followed for a computer to perform calculations or other problem-solving operations.According to its formal definition, an algorithm is a finite set of instructions carried out in a specific order to perform a particular task. It is not the entire program or code; it is simple logic to a problem ...

  8. Problems, Solutions, and Algorithms

    What is an Algorithm a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer. Incremental solutions (linear) Iterative solutions (spirals) Building a full "slice" "Half a product not a half-assed product" An Iterative Process

  9. What is an Algorithm?

    In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem. It takes a set of input (s) and produces the desired output. For example, An algorithm to add two numbers: Take two number inputs. Add numbers using the + operator. Display the result.

  10. What is an algorithm?

    An algorithm is a procedure used for solving a problem or performing a computation. Algorithms act as an exact list of instructions that conduct specified actions step by step in either hardware- or software-based routines. Algorithms are widely used throughout all areas of IT. In mathematics, computer programming and computer science, an ...

  11. A set of problem-solving operations in a computer

    Please find below the answer for A set of problem-solving operations in a computer. CodyCross is one of the most popular games which is available for both iOS and Android. This crossword clue belongs to CodyCross Rainforest Group 1212 Puzzle 3. The answer we have below for A set of problem-solving operations in a computer has a total of 9 letters.

  12. How to Use Algorithms to Solve Problems?

    End - End the execution. Let's take some examples of algorithms for computer science problems. Example 1. Swap two numbers with a third variable. Step 1: Start. Step 2: Take 2 numbers as input. Step 3: Declare another variable as "temp". Step 4: Store the first variable to "temp". Step 5: Store the second variable to the First variable.

  13. Discover how computers solve problems

    Computers can solve problems by performing billions of operations per second. A programmer's job is to find solutions. They do this by breaking down problems into easy-to-follow steps for a computer. Programming languages allow people to communicate with computers. Computers are literal and do exactly what you tell them to. #

  14. Algorithms in Real Life: What is an Algorithm?

    Definition. With a quick Google search, we see that an algorithm is defined as "a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.". This might sound like a riddle to you. There are so many definitions on the internet that do not clearly explain what algorithms actually do.

  15. Algorithm

    An algorithm is a set of instructions for accomplishing a task that can be couched in mathematical terms. ... əm / • n. a process or set of rules to be followed in calculations or other problem-solving operations, esp. by a computer: a basic algorithm for division ... but under the influence of computing now regarded as a step-by-step ...

  16. Computer Program vs. Algorithm

    An algorithm is a self-contained step-by-step set of operations to be performed to solve a specific problem or a class of problems. A computer program is a sequence of instructions that comply the rules of a specific programming language , written to perform a specified task with a computer. Algorithms are general and have to be translated into ...

  17. PDF CSC 171

    Computer Programming Lecture #5 - Algorithms and Program Development What is an Algorithm? •Process or a set of rules to be followed in calculations or other problem-solving operations more informally a recipe for solving a problem. 2 Example : Square Root Algorithm 1. Guess the square root of the number

  18. Algorithm Definition & Meaning

    The meaning of ALGORITHM is a procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation; broadly : a step-by-step procedure for solving a problem or accomplishing some end. How to use algorithm in a sentence. What Does algorithm Mean?

  19. PDF Introduction to Problem Solving

    to apply problem solving techniques. Problem solving begins with the precise identification of the problem and ends with a complete working solution in terms of a program or software. Key steps required for solving a problem using a computer are shown in Figure 4.1 and are discussed in following subsections. 4.2.1 Analysing the problem

  20. MIT School of Engineering

    Complex math requires the handling of two types of operations: numerical ones that involve specific numerical values, and symbolic ones, such as those in algebra and calculus, that involve symbols like "x" and "y.". Moses notes that numerical operations can be broken into addition, subtraction, multiplication, and division, which are ...

  21. Computational Thinking: How computers think, decide and learn ...

    In one dictionary's definition, an algorithm is a "process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer."

  22. Algorithms Unit 5 Flashcards

    a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer. a method for finding a target value within a list. by sequentially checking each element of the list for the target value until a match is found or until all the elements have been searched.

  23. Basics of Computer and its Operations

    A computer is an electronic device that can receive, store, process, and output data. It is a machine that can perform a variety of tasks and operations, ranging from simple calculations to complex simulations and artificial intelligence. Computers consist of hardware components such as the central processing unit (CPU), memory, storage devices ...

  24. AP CSP unit 2- Algorithms Flashcards

    Study with Quizlet and memorize flashcards containing terms like What is a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer? A. algorithms B. big o notation C. structured english D. Unambiguous, All algorithms can be constructed using what three basic parts A. Sequence, selection, and standards B. Standards, iteration, and ...

  25. Water Jug Problem in AI

    The Water Jug Problem is a classic puzzle in artificial intelligence (AI) that involves using two jugs with different capacities to measure a specific amount of water. It is a popular problem to teach problem-solving techniques in AI, particularly when introducing search algorithms.The Water Jug Problem highlights the application of AI to real-world puzzles by breaking down a complex problem ...