An algorithm is a set of steps designed to solve a problem or accomplish a task. Algorithms are usually written in pseudocode, or a combination of your speaking language and one or more programming languages, in advance of writing a program. This wikiHow teaches you how to piece together an algorithm that gets you started on your application.

Steps

  1. 1
    Determine the outcome of your code. What is the specific problem you want to solve or the task you want it to accomplish? Once you have a solid idea of what you're aiming to accomplish, you can determine the steps it will take to get there.
  2. 2
    Decide on a starting point. Finding your starting and ending point are crucial to listing the steps of the process. To determine a starting point, determine the answers to these questions:[1]
    • What data/inputs are available?
    • Where is that data located?
    • What formulas are applicable to the issue at hand?
    • What are the rules to working with the available data?
    • How do the data values relate to each other?
    Advertisement
  3. 3
    Find the ending point of the algorithm. As with the starting point, you can find the end point of your algorithm by focusing on these questions:
    • What facts will we learn from the process?
    • What changes from the start to the end?
    • What will be added or no longer exist?
  4. 4
    List the steps from start to finish. Start with broad steps. To use a real-world example, let's say your goal is to have lasagna for dinner. You've determined that the starting point is to find a recipe, and that the end result is that you'll have a lasagna fully cooked and ready to eat by 7 PM. Your steps may look something like this:
    • Search for a recipe online.
    • Look for the ingredients you already have in the kitchen.
    • Make a list of ingredients you'll need from the store.
    • Buy the missing ingredients.
    • Return home.
    • Prepare the lasagna.
    • Remove the lasagna from the oven.
  5. 5
    Determine how you will accomplish each step. Now that you have a step-by-step outline, it's time to think about how you might code each step. Which language will you use? What resources are available? What's the most efficient way to accomplish each step in that language? Incorporate some of that code into your algorithm. Expand each step until you've detailed the entire process.
    • For example, the first step in our lasagna algorithm is Search for a recipe online. But what is involved in this search? Be specific. For example:
      • Turn on your computer.
        • Check to make sure you're connected to the internet. Connect to the internet if you aren't already.
      • Open a web browser.
      • Enter your search terms.
      • Click a recipe link.
      • Determine whether the recipe meets your needs.
        • Filter out recipes that aren't vegetarian.
        • Make sure the recipe makes at least 5 servings.
      • Repeat some of these steps until you find the right recipe.
    • Consider the resources at your disposal, such as the capabilities of the system you're developing a program for. In the case of lasagna, we assume the person making the lasagna knows how to search the internet, operate an oven, etc.
  6. 6
    Review the algorithm. Now that you've written your algorithm, it's time to evaluate the process. Your algorithm is designed to accomplish something specific, and you'll need it to start writing your program. Ask yourself the following questions, and address each as necessary:[2]
    • Does the algorithm solve the problem/accomplish the task?
    • Does it have clearly defined inputs and outputs?
    • Should the end goal be redefined to be more general? More specific?
    • Can any of the steps be simplified?
    • Is the algorithm guaranteed to end with the correct result?
  7. Advertisement

Community Q&A

  • Question
    How do I write an algorithm that 7 is greater than 5?
    nicholasz2510 Gaming, Travel, and Music
    nicholasz2510 Gaming, Travel, and Music
    Community Answer
    The syntax can vary over different languages, but to write the conditional 7 is greater than 5 would most likely by simply be this: 7 > 5.
  • Question
    How do I make an algorithm of the sum of two numbers?
    Adam Blalock
    Adam Blalock
    Community Answer
    To add two numbers in a programming language, you just use a "+" between them. In Python (a programming language), it would look like: x = 10, y = 13; print x + y.
  • Question
    Is there any way to understand this easier? I'm 15 and still trying to understand the concepts.
    Community Answer
    Community Answer
    I just started programming and my college professors are very vague and make understanding the concepts pretty hard. Your best bet is to keep looking up the terms on Google, that's what I've been doing, and it works to a degree.
Advertisement

About This Article

Nicole Levine, MFA
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 434,213 times.
How helpful is this?
Co-authors: 26
Updated: September 21, 2021
Views: 434,213
Categories: Programming
Article SummaryX

1. Determine the problem or task to accomplish.
2. Decide the starting point.
3. Figure out the endpoint.
4. List the steps that occur between the start and finish.
5. Break down the steps as necessary.
6. Review the algorithm and change where necessary.

Did this summary help you?
Advertisement