<ol>
<li><p>Practice.  Thinking algorithmically is a skill, and skills develop with focused practice over time.  All of the relevant-to-life examples in previous answers are forms of practice that will result in some skills transfer to computer algorithms and also maintain student interest.  You could add some basic mathematical algorithms that students know to the pool of practice exercises.  Work through the algorithms for addition and subtraction and translate them into pseudocode.  Something like "sort a deck of cards" is perhaps an ideal example because sorting is something that people sometimes do in real life and also something that we actually program computers to do (unlike "make a PB&amp;J" or "perform addition in base 10").  </p>

<p>Practice exercises should be assessed by the teacher and used to help identify areas where students are having conceptual difficulties with the material.  </p>

<p>You can also give students a simple algorithm for debugging their code, which both reinforces algorithm following and also teaches the separate valuable skill of debugging their code.  Steps could include "read the error message", "check for syntax errors", "google the error message", "explain your problem out loud to a rubber duck", etc.</p></li>
<li><p>Teach subskills.  "Thinking algorithmically" is a huge skill with many subskills.  Break algorithmic thinking into its subskills and teach them individually:</p>

<ul>
<li>Identify inputs and outputs.  </li>
<li>Identify repetition/repeatable steps.</li>
<li>Identify success and failure conditions.</li>
<li>Identify problems that lend themselves to an algorithmic solution and reframe problems in ways that clarify what the algorithm needs to do.</li>
<li>Select and employ an algorithmic strategy to attempt to solve a problem.</li>
<li>Test potential solutions on a number of datasets.</li>
</ul>

<p>Learning and practicing these subskills explicitly will help to ensure that students are thinking and communicating very clearly about the problems they are trying to solve an the methods they are trying to use.  This clear thought and communication is really the only way that students have a hope of understanding more complicated and abstract problems and solutions.</p></li>
<li><p>Teach strategies.  Iteration and recursion, divide-and-conquer, dynamic programming, greedy algorithms.  I found a <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=4&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwiyx57emcfUAhUGvhQKHaOxDSwQFgg4MAM&amp;url=https%3A%2F%2Fwww.cis.upenn.edu%2F~matuszek%2Fcit594-2007%2FLectures%2F27-algorithm-types.ppt&amp;usg=AFQjCNGRn6TenIDttsYL66V6Wq2nAFKHlQ&amp;sig2=KjcKY08LIswt7q8c72Y4Og" rel="nofollow noreferrer">power point presentation</a> with some basic algorithm types and simple examples that demonstrate those types, many of which could be adapted for students at that age level.  For example, the four-color map algorithm could actually be done by students on paper, and can be a lot of fun (I've used the four-color theorem in lessons before and the kids loved it); the counting money algorithm (make a certain amount of money with the least number of coins and bills) could also be very accessible and relevant for students.  </p></li>
</ol>

CC BY-SA 3.0
2017-06-18T11:11:27.410Z
2017-06-18T11:15:25.773Z
2017-06-18T11:15:25.773Z
Neal Zupancic
<p>Do you know about the initiative called Scratch?  </p>

<p>It's a visual and algorithmical language, it can be useful as an introductory subject for your students.    </p>

<p>In scratch you can visually build loops, conditionals, functions, and return events, it's a whole language that is more approachable to beginners, and maybe might incite more their inquisitive nature. </p>

<p>It helps by literally making them shape visually an algorithm or program, they could also share it with fellow students and get other's code from the community, it also has some fun features such as running a loop to play sounds or images.</p>

<p>It's also used briefly in <strong>CS50: Introduction to Computer Science</strong> from Harvard.   </p>

<p>You might want to give it a try, it could help your students, especially since they are so young.   </p>

CC BY-SA 3.0
2017-06-16T20:55:03.210Z
Welcome to CSE!  We're very glad to have you here.  This answer needs a little work, though. How will this help OP's students to think algorithmically?
Ben I.
CC BY-SA 3.0
2017-06-16T20:58:02.343Z
In scratch you can visually build loops, conditionals, functions, and return events, it's a whole language that is more approachable to beginners, and maybe might incite more their inquisitive nature. 
It helps by literally making them shape visually an algorithm or program, they could also share it with fellow students and get other "code" from the community, it also has some fun features such as running a loop to play sounds or images.
Eliâ Melfior
CC BY-SA 3.0
2017-06-16T21:00:56.487Z
Good improvements.  Keeping the quality of the questions and answers high here is a really big deal, because it's what makes the whole enterprise worthwhile.  I hope to keep seeing you around the site!
Ben I.
CC BY-SA 3.0
2017-06-16T20:49:59.810Z
2017-06-16T21:02:02.713Z
2017-06-16T21:02:02.713Z
Eliâ Melfior
<p><a href="http://blog.karhatsu.com/2014/09/experiences-from-programming-with-kids.html" rel="nofollow noreferrer">Here's an enlightening blog post</a> about teaching programming to elementary school age children. They started without any computers at all by "programming" the teacher to walk from one corner of the class to the other using few simple commands. They then proceeded to use the <a href="http://turtle-roy.herokuapp.com/" rel="nofollow noreferrer">Turtle Roy</a> online programming environment which works like the <a href="https://en.wikipedia.org/wiki/Logo_(programming_language)" rel="nofollow noreferrer">Logo programming language</a> and teaches you to think algorithmically, with visual results that are immediately visible.</p>

CC BY-SA 3.0
2017-06-17T08:54:56.150Z
This is a good answer, but if you can add details about how Turtle Roy teaches you to think algorithmically, it would really make this into a great answer.
ItamarG3
CC BY-SA 3.0
2017-06-17T15:19:00.583Z
Also, welcome to CSE!
Ben I.
CC BY-SA 3.0
2017-06-17T07:04:54.353Z
2017-06-17T07:04:54.353Z
ZeroOne
<p>Algorithmic thinking can perhaps best be taught completely apart from coding in the classes given programming language(s).</p>

<p>I might have one student tell another student how to solve a fairly easy problem on a whiteboard, but only communicating one step at a time using a constrained set of commands, for instance only one input, one arithmetic operation step, or one saved result at a time.  Maybe have the algorithm developer write out the steps while the operator student is out of the room, them have the operator come back into the room and execute the written algorithm on the whiteboard.</p>

<p>One example might be averaging N numbers, where student A writes an algorithm, student B later provides the numbers one at a time, then student C uses the algorithm to compute a result, while the class watches.</p>

CC BY-SA 3.0
2017-06-17T20:27:55.413Z
2017-06-17T20:27:55.413Z
hotpaw2
<p>Rather than giving them processes to model algorithmically, have them start coming up with algorithms for everyday activities. Here is the formal assignment I have students complete: <a href="http://cdn.cs50.net/ap/1516/problems/0/2/0-2.html" rel="noreferrer">CS50 AP - Everyday Algorithms</a>.</p>

<p>They begin with a simple pseudocode example:</p>

<pre><code>1   look out the window
2   if it is raining outside
3      put on your rain boots
4      put on your raincoat
5   go outside
</code></pre>

<p>After they get comfortable with pseudocode, students write their own simple algorithm:</p>

<blockquote>
  <p>Okay, now you’ve learned a lot about algorithms and pseudocode.
  Perhaps we should try writing a few—three, to be precise. First, write
  up algorithms (both in sentence form and in pseudocode) for how to:</p>
  
  <ul>
  <li><p>brush one’s teeth</p></li>
  <li><p>eat an orange</p></li>
  </ul>
  
  <p>Next, think of something that you do every day or nearly every day.
  Write an algorithm in sentence form and in pseudocode for how to do
  the thing you’re thinking of.</p>
</blockquote>

<p>Students will take more ownership and may understand it new ways if they are coming up with the processes to model based on something important to them. While your example certainly works well, what about students for whom getting a paycheck is unfamiliar territory? You want to use a student's prior knowledge to your advantage, so the focus is solely on the algorithm, not the algorithm <em>and</em> some other idea.</p>

<p>Another essential element I found to getting students to think algorithmically is to model it in all things I do at the start of the year. Everything is a process as follows: <code>input -&gt; algorithm -&gt; output</code>. Let's say I want to take attendance or assign seats. I think out loud with an algorithmic process. My input is an uncounted group of students, and my desired output is a counted group as a means of attendance. Here's the algorithm I use, which I borrow from <a href="http://cdn.cs50.net/2015/fall/lectures/0/f/notes0f/notes0f.html" rel="noreferrer">CS50's first lecture at Yale</a>:</p>

<pre><code>1 stand up and assign yourself the number 1
2 pair off with someone standing, add your numbers together, and adopt the sum as your new number
3 one of the pair should sit down; the other goes back to step 2
</code></pre>

<p>The value of this exercise is it gets student moving. <strong>Differentiation is essential for teaching students to think in a new way. Get them moving and talking to each other. Make it relevant to their everyday experience.</strong></p>

CC BY-SA 3.0
2017-06-16T19:41:21.113Z
This is the exact approach my first programming teacher used on my class.  Breaking down "How do you make a peanut-butter and jelly sandwich" in to individual steps is permanently associated with programming for me now.  It was immensely helpful.
Bradley Uffner
CC BY-SA 3.0
2017-06-15T19:05:37.353Z
2017-06-18T14:56:49.703Z
2017-06-18T14:56:49.703Z
Peter
<blockquote>
  <p>How do you teach students of this age and ability to think algorithmically?</p>
</blockquote>

<p>I don't really think there's a silver bullet to this problem. To be able to think algorithmically, <strong>you need to solve lots of problems, over and over</strong>. Some students will naturally have the ability to be able to describe algorithms without much teaching, but it's not a universal skill, and it comes at different rates for different people.</p>

<p>In an ideal world, adapting the level of difficulty of the algorithms to design would be useful: get an easy algorithm right, and then move on to a harder one, until you get stuck, and then go back down until you master algorithm design for even complex problems. However, that would require a lot of attention to do in person, so to get that level of support, you need an automated solution.</p>

<p>I highly recommend <a href="https://www.codewars.com/" rel="noreferrer">Codewars</a> as a good tool to practice solving simple problems that scale up in difficulty—I had great fun trying some myself a while back. </p>

<ul>
<li><p>A task (kata) is given with instructions, example outputs and (usually) pre-made unit tests.</p></li>
<li><p>You input your solution, test it, then submit. Codewars runs it against (hidden) tests to make sure the solution is valid, and then if so, you gain points.</p></li>
</ul>

<p>You can create 'Clans' (perhaps for your class) so a league table is shown—the gamification might be a good motivator for some.</p>

<p>The difficulty of the kata increases as you get better (and harder kata give higher rewards), so the difficulty should ramp up and help students develop their skills.</p>

<p>This, of course, does require students to be relatively comfortable with the <em>syntax</em> of at least one programming language. If you've not taught any of the language itself yet, you probably should do that before you teach algorithmic thinking—a basic handle on how a programming language is used would probably be useful so that students can understand what an algorithm can and can't do.</p>

CC BY-SA 3.0
2017-06-22T18:04:31.023Z
See also: [Code Golf SE](https://codegolf.stackexchange.com/). While I don't expect students to start golfing their code (<shudder>), the sorts of challenges that come up are the ones that are generally good to present. Particularly the ones tagged [kolmogorov-complexity] which is all about expressing something complex as a series of simpler instructions. Algorithms are for finding short cuts by doing the same operation multiple times instead of copy-pasting and why I don't like most of the other answers.
Draco18s no longer trusts SE
CC BY-SA 3.0
2017-06-15T17:12:21.577Z
2017-06-15T17:12:21.577Z
Aurora0001
<p>Since all the other great answers are all given, let me mention a minor one.  <a href="http://www.folj.com/lateral/" rel="noreferrer">Lateral thinking Puzzles</a> are good for this.  They help to teach children to think in a different manner by themselves and encourage general problem solving.</p>

<p>However, they can be used to teach one important part of algorithms, the need for rigor in your statements, if one chooses to go that route.  Pick some of the easier lateral thinking puzzles, but threaten to answer questions exactly as a computer will.</p>

<p>You find that many times people ask questions different then they intend to.  They phrase things wrong, or they hear one answer but assume you meant something else.  If you are very <em>very</em> exact in your answering you can make a puzzle hard to solve simply because people interpert your answers very different from what you literally said.</p>

<p>I would also include things like "does not computer" for questions that aren't well phrased, some 'standard' ammusing response to questions that are not yes or no questions. etc.  Most importantly, remember in your head some examples where you can see the children misunderstood your answers or made ralse presumptions.  Then after a puzzle is solved show them their mistakes and explain to them how they lacked rigour in their questions and how that lead to confusion, it's a good analogy for how you need to approach computers that are 100% literal and do exactly what you told them to, but not always what you meant for them to do.</p>

<p>This works best with "false assumpiton" puzzles that are written in such a way as to trick people into assuming something about the premis that wasn't said.  for example:</p>

<ul>
<li>use a pronoun to refer to someone who is also refered to by name, so they presume two people are relevant instead of one person refered to in two ways (aliasing!)</li>
<li>Any puzzle that doesn't use humans as the premise, "Tom killed Jerry but no one cared, why?", because Tom and Jerry are a cat and mouse.</li>
<li>Trick someone by confusing sex, talk about "Alice and Kris" doing something where people presume Kris is male and the puzzle the mystery is obvious if one realizes Kris is female.</li>
<li>Other presumptions that are false.  Maybe Alice and Kris went out on a date together, they saw a movie and then went out to eat, but after the dinner Kris refused to pay for Alice dinner and left immediately without giving Kris a ride back home.  He proceed to complain about how horrible his date was to everyone the next day at school.  Alice wasn't upset by any of this, why not?", turns out their both female and on a double date, Alice's dinner and ride home was provided by the boy she was dating and isn't offended that Kris didn't like the boy she dated.  </li>
</ul>

<p>This sort of questions teach the children to learn to check their presumptions and how to ask properly rigorous questions to verify information, even get's them into the mindset needed to debug broken code by knowing what to ask to narrow down a problem.</p>

<p>I've used these sort of things to prepare young kids for the mindset required for programming, but these were kids I was mentoring and spent a bit of time with.  It takes a little time to do a puzzle with kids, and while I found they helped me to communicate programming ideas I don't know if they provide so much benefit as to warrant class time spent on them?  If nothing else these could be good things to do during 'dead' time, before class officially starts, on the bus during a field trip, while waiting outside during a fire alarm, etc to entertain kids while sneaking in some extra training.</p>

CC BY-SA 3.0
2017-06-19T16:43:40.230Z
2017-06-19T16:43:40.230Z
dsollen
<p>The problem as described is simply translation from one firm of words to another, so in some senses, students may not really grasp what you are asking for. I think a more important thing to ask for is to construct algorithms from a less structured problem. </p>

<p>A flow chart is just another way to write the algorithm, not really a progression - and not necessarily useful.</p>

<p>I suspect one major challenge with thinking algorithmically is the ability to break down the problem into the <strong>right number</strong> of steps, with those steps at the <strong>right level</strong> of abstraction. People often tend to focus on either the parts that they know, or the parts that they don't know.</p>

<p>An approach that may help is <em>successive refinement</em> where you try to sub-divide the problem in small steps. Inputs and outputs being an obvious thing to try first. The aim is to avoid getting stuck in the minute details, or blocked on a part that you don't know where to begin. Progress on one area will often give some ideas about how to solve another.</p>

CC BY-SA 3.0
2017-06-15T18:18:28.510Z
2017-06-15T20:06:29.463Z
2017-06-15T20:06:29.463Z
Sean Houlihane
<p>Sounds like you've tried everything already, but here are some suggestions:</p>

<ul>
<li><p>Use a scenario / problem that every student can relate to</p>

<blockquote>
  <p>Most of my lower ability 13-14 year old boys don't have much experience of wages, tax and jobs. Writing an algorithm for making a perfect cup of tea doesn't do much for them either. Drawing a flow chart for <strong>how to irritate a teacher</strong> and comparing it to <strong>how to get a merit / positive / reward / whatever the equivalent in your school</strong> is always a memorable lesson.</p>
</blockquote></li>
<li><p>Give them lots of practice at understanding pseudocode before asking them to write it</p>

<blockquote>
  <p>Getting students to physically act out instructions can be time consuming and patronising but can also be really helpful for students struggling to visualise the sequence. Getting students to take turns giving instructions to sort numbers (bits of paper stuck to a wall) is a good way of doing this. Alternatively, you can set some challenges <a href="http://tools.withcode.uk/ks4pseudo/" rel="noreferrer">like this</a> so students can work through the process of following instructions, ideally with instant feedback if they get each one right.</p>
</blockquote></li>
<li><p>Give them broken algorithms to fix</p>

<blockquote>
  <p>This works really nicely as a team activity. First, students work in pairs to diagnose and fix problems in algorithms you give them and then they design algorithms for each other with some obvious mistakes. The mistakes could be using the wrong symbols in a flowchart (leading to a discussion about syntax errors), writing a statement that doesn't really make sense (leading to a discussion about needing crystal clear, unambiguous instructions) or writing an instruction that's just plain wrong (leading to a discussion about logical errors)</p>
</blockquote></li>
</ul>

CC BY-SA 3.0
2017-06-16T11:37:48.260Z
2017-06-16T11:37:48.260Z
pddring
<ul>
<li><p>One thing that helps in my experience (albeit with older students) is to give a pseudo-code cheat-sheet and insist that the problem has to be solved only using the building blocks on the sheet. In particular, you must insist that anything that is not on the list must be written using the building blocks. </p>

<p>So if at some point they need to fill an array with something, there is no magical "fill the array" step. The students have to first define it in terms of increment, for loops, or whatever you have in the pseudo-language. And that is the hard part. What do you allow in your pseudo-code? Side effects? Functions vs Procedure? By-value, and by-reference parameter passing? It all depends.</p></li>
<li><p>One way to reach the point where you can actually write pseudo-code, is to start from slightly more general problem statements, then refine it in smaller steps, and then again, until you arrive toward something that is pseudo-code. In your example I would start the exercise by asking just <strong>"Devise an algorithm that calculates a user’s paycheque based on the hourly rate and the number of hours."</strong></p>

<p>I would let the student work collectively while guiding them and only let them do the actual last step (English -> pseudo-code) individually. And gradually help them less and less. For instance a student might say "oh you multiply early rate by number of hours and done". Yes but where do you get the rate and hours from? <em>"Huh? Maybe I need to read them from somewhere or ask the user"</em>. And what do you do with the result ? <em>"Oh yes
that's right I have to display it"</em> etc... And then when you have all the bits, put them in order and express them using pseudo-language.</p></li>
</ul>

CC BY-SA 3.0
2017-06-16T06:14:39.580Z
2017-06-16T10:48:57.683Z
2017-06-16T10:48:57.683Z
Kim Nguyễn
<p>I just finished up 8th grade.</p>

<p>I took an Intro to Engineering/Robotics class as an elective this past semester. I have programmed (mainly in Python 3) before this class, and I was mainly excited for the Robotics part. When we started, the teacher talked to us about how the computer takes things very literally, etc, etc, and then - he had us pretend he was the robot. So he told us to "program" him to get to the door. Someone forgot to tell him to turn, so he literally walked into a wall. Another person got him too close to the door, so when someone else told him to lift up his arm - hit the door. So he walked us through that.</p>

<p>Then he gave us very simple exercises - turn the motor on at such and such speed for this time, and then stop it, and had us write out the pseudo code, check it with him, and then turn it into regular code, and so on. As the problems got more complex, the pseudo code got more and more important. One problem, the full solution's code was much more complex, and so he had most people do it an easier way, but he let me try the full solution, so I worked on it, and he had me diagram a part up on the whiteboard for him, and so on, and it worked.</p>

<p>I guess the point is, give an illustration - like the PB&amp;J one that seems to be popular, or this one, and then emphasize pseudocode as they solve simple problems, and eventually, as the problems get more complex, it will serve them well. The key is to have them do tons of programming, and eventually it will come more naturally.</p>

<p>Another idea is to do a form of code golf - have people come up with solutions, pick a slower/longer solution, and encourage ideas to make it more efficient, and so on, until you have a much more ideal piece of code. </p>

CC BY-SA 3.0
2017-06-17T15:19:52.833Z
Welcome to CSE! You are very articulate young lady. I hope we hear more from you as you continue to learn about computer science. :)
Ben I.
CC BY-SA 3.0
2017-06-17T15:10:39.187Z
2017-06-17T15:10:39.187Z
auden
<p>I remember a demonstration from early in my first college CS course (this was in 1998, almost 20 years ago!), where the professor brought in a loaf of bread, a butter knife, a jar of peanut butter, and a jar of jelly. He then asked the class to give him instructions to make a peanut butter sandwich, with predictably hilarious results. After we had finally created the first messy sandwich, he had us repeat the exercise, but this time we had to record the steps on the board in advance. Then he followed the steps, again with hilarious results.</p>

<p>The point, of course, was to first teach us that computer will always take things literally, always do exactly what you tell them, and that mistakes early in the process can cause good instructions later on to have bad results. It's important that <em>both</em> the algorithm be correct, and that each instruction that composes the algorithm is correct. It also demonstrated the degree to which we rely on common abstractions and idioms that are often not perfectly represented in the computer.</p>

<p>At the college age, I felt like it was kind of simplistic for us. But for 13-14 year olds this would be perfect.</p>

CC BY-SA 3.0
2017-06-16T15:11:54.827Z
Please do not remove the parenthetical about the date. The remark isn't just a side-note; it shows that the demo had staying power on impressionable young minds.
Joel Coehoorn
CC BY-SA 3.0
2017-06-16T15:16:03.030Z
Quite right, my apologies.
ItamarG3
CC BY-SA 3.0
2017-06-16T15:20:20.077Z
I did almost exactly this lesson for years, but I added a computer program into the mix - I created a PB&J simulator, with a syntax and a set of instructions. They had to open and close drawers with their two hands, take out plates, knives, etc... I pasted their "code" into my simulator, and if the end result was a sandwich, they were allowed to actually make it *only following their own instructions*.  There were some peanut-buttery hands in that classroom ;-)
Ben I.
CC BY-SA 3.0
2017-06-19T16:24:25.690Z
I was going to recommend this.  The younger the children the better it works.  However, it's important not to focus too much on funny failures (as is tempting to do) if your doing this to start stressing algorithms in general.  Make sure to try to act like a computer, including simply failing to do anything for some invalid input (rather then doing the wrong thing).  if someone uses poor english syntax give them a syntax error.  if someone tells you something too general tell them you don't now that method/keyword, try to focus on a small set of 'predefined' API calls you understand.
dsollen
CC BY-SA 3.0
2017-06-19T16:25:20.893Z
Oh, also make sure you ask about peanut allergies ahead of time!!  or maybe just be on the safe side and stick with a jelly sandwich.
dsollen
CC BY-SA 3.0
2017-06-16T15:07:39.793Z
2017-06-16T15:13:33.010Z
2017-06-16T15:13:33.010Z
Joel Coehoorn
<p>I'm a bit confused by your question.  Your exercise seems to involve some combination of…</p>

<ol>
<li>Requirements gathering: what are the inputs, outputs, and formulas?</li>
<li>Translating the requirements to a conceptual model</li>
<li>Translating the conceptual model to pseudocode</li>
<li>Translating the pseudocode to code</li>
<li>Translating the pseudocode or code back to a flowchart (Why?  In decades of programming experience, I've almost never found flowcharts to be useful.  If anything, they encourage an if-then-goto mentality, which is the opposite of <a href="https://mitpress.mit.edu/sicp/" rel="noreferrer">what you want to aim for</a>.)</li>
</ol>

<p>It's not clear from your question which parts of the exercise are provided to the students as givens, and which parts you expect the students to perform.</p>

<p>In any case, "Devise an algorithm that calculates a user’s paycheque" is <em>much</em> too open-ended a question for a beginner!  All of those steps expect students to produce some output starting from a blank slate, which can be intimidating.</p>

<p>Furthermore, I'm not convinced that this exercise teaches useful <em>computer science</em> concepts.  It may be a useful demonstration of what programmers do, but that's not quite the same thing.</p>

<hr>

<p>As an alternative, I suggest giving exercises where the inputs, outputs, and expected behaviour are obvious.  The correctness of the response should be easily testable.</p>

<p>For kids, you could try <a href="https://codecombat.com" rel="noreferrer">Code Combat</a> or <a href="https://code.org/learn" rel="noreferrer">Code.org's exercises</a>.  Some of the exercises can be done in visual programming environments using drag-and-drop blocks (like <a href="https://scratch.mit.edu" rel="noreferrer">Scratch</a> or <a href="https://snap.berkeley.edu" rel="noreferrer">Snap</a>), eliminating the fear that some students encounter when asked to write something starting with an empty screen.  If you're looking for more "traditional" programming environments, you could try <a href="https://en.wikipedia.org/wiki/Karel_%28programming_language%29" rel="noreferrer">Karel</a> exercises, which have been ported to a variety of programming languages.  These exercises all encourage students to develop algorithms — mainly to move characters on a board in a specified pattern.  In contrast to your open-ended exercise, these are highly guided activities, which gradually increase in difficulty.</p>

<p>Once students have mastered the concept of developing algorithms to solve problems with extremely well specified inputs and outputs, then they can be asked to apply those ideas to real-life problems, where the inputs are not fixed, the scope is unclear, and requirements are negotiable.</p>

CC BY-SA 3.0
2017-06-17T01:44:19.310Z
This is a beautiful answer. Very well thought out. Welcome to CSE! I hope we hear more from you.
Ben I.
CC BY-SA 3.0
2017-06-17T00:23:23.827Z
2017-06-17T01:47:39.527Z
2017-06-17T01:47:39.527Z
200_success
<p>Thinking algorithmically isn't always natural.  In an algorithm, you're going to write down everything the computer is going to, then hit "go" and step away for a few microseconds while the computer does it.  In most of our lives, there's more back-and-forth in our interactions, so it takes a while to get used to thinking in this one-pass approach.</p>

<p>Something I think would be helpful is an origami game.  It's <em>really</em> hard, but an excellent introduction to thinking like this.  The game works like this:</p>

<ol>
<li>Teams are split into two groups (minimum team size of 2, obviously)</li>
<li>One group is given a folded origami creation and pictoral instructions on how to make it.</li>
<li>That group must create <em>written</em> (not pictural) instructions to make the object.</li>
<li>Those instructions are then given to the second half of the team, who have to create the orgami from those instructions.  They do not get to see the pictorial instructions nor what the final product should look like.</li>
</ol>

<p>A few rounds through that will quickly teach them what works and what doesn't.</p>

<p>It also makes you <em>really</em> appreciate your debugger!</p>

CC BY-SA 3.0
2017-06-15T19:36:16.457Z
2017-06-15T19:36:16.457Z
Cort Ammon
<p>The biggest problem is moving students to a difficult algorithm before they have mileage with simple ones.
The best way I've found is </p>

<p>a.  Go over the classic small algorithms, especially array and string based.
 - e.g. find the sum, min, max, do a swap.</p>

<p>b. give students many small algorithmic problems to solve. I use the exercises at codingbat.com which were written Nick Parlante, a lecturer at Stanford. I give a lot of level 1 problems, and can usually get them to level 2 near the end of the semester.</p>

<p>Another thing I do is, every lab has a prelab consisting of a bunch of code interspersed with print statements, asking "What does this code print?" I believe that tracing code strengthens students' algorithmic thinking as well.</p>

<p>Finally, homework assignments before the lab with code tracing and writing code snippets also help students a lot.</p>

CC BY-SA 3.0
2017-06-27T16:41:28.567Z
2017-06-27T16:41:28.567Z
user1462
<p>Even though it can be complicated, recursion gives a great algorithmic view of problems. I have seen quite a few students start to think in an algorithmic way after I introduce recursion (just very simple problems such as printing the individual characters of a string. I'll refer to this exercise as an example task throughout the answer). </p>

<p>This gives them the basic idea of what thinking in an algorithmic way means. I go with them every step of the way, and make sure that they all understand exactly what's going on. </p>

<p>Then, I go on to saying that the core of algorithmic thinking is breaking a problem into smaller problems that are very similar to one another (sort of like doing an operation on a tree; you preform on a node, and then on it's children, and so on). </p>

<p>Usually I find it useful to have a classroom discussion on how one deals with big problems/tasks. I lead them to the conclusion that they need to break it into smaller problems, conceptually, before they can write a code that tackles the big problems. This gets the notion of treating problems as a collection of easy tasks that are solved one at a time in a similar manner. </p>

<p>After saying this, I remind them the small recursive task from the beginning. All the program does is print the first letter of the given string. That's easy to the point of ridiculous. </p>

<p>This way, the students understand that algorithmic thinking is just breaking a problem into smaller problems that they know how to solve. A part of algorithmic thinking is turning the input into a form or structure that they can handle in an easy way. This is shown in the example task by turning a string, which is a bit more complex than a single character, into a single character. This is the process of simplification of the problem, which is essential in algorithmic thinking. </p>

<p>From students' feedback, this method works very well. In fact some students start searching (pun intended) for search algorithms and they quickly find and use alpha-beta pruning, minmax and others. They really get the idea of thinking algorithmically. </p>

CC BY-SA 3.0
2017-06-16T13:56:30.827Z
@nocomprende that's really non constructive for the students
ItamarG3
CC BY-SA 3.0
2017-06-16T07:09:30.097Z
2017-06-16T07:09:30.097Z
ItamarG3
<p>So far in my career, when I have a student who just <em>doesn't seem to get it</em> (and there is no obvious discernible cause) it very often comes down to one of two problems.</p>

<p>The first is <strong>mutability</strong>, which I wrote a little piece about <a href="https://cseducators.stackexchange.com/a/345/27">here</a>.  Kids who can't easily trace how values will change need explicit practice in this concept before they will really be able to follow what is going on in imperative languages, and it can take a surprising amount of practice to help them to really <em>get</em> it.  The fact that it's so easy to describe is disarming, because we think they get it.  And the kind of extremely simple code that we might use to determine understanding often doesn't trigger the kinds of incorrect responses that would naturally call teachers to action.  However, as soon as the code itself starts gaining any complexity, having a cloudy notion of mutability is a game-stopper, pure and simple.</p>

<p>The second is <strong>simple motivation</strong>.  For the kids who aren't so quick with CS at the start, not being willing to put extra thought and effort into the topic halts their growth.  I don't have a lot of generalized insight into how to fix this one.  When I have unmotivated kids, they mostly just kind of muddle through.</p>

CC BY-SA 3.0
2017-06-16T13:55:27.517Z
It's the right question, and I agree with you. I try to give free choice in labs when I can, but sometimes kids stick with it past add/drop, and then you are all stuck with each other.
Ben I.
CC BY-SA 3.0
2017-06-15T17:53:56.550Z
2017-06-16T13:54:11.600Z
2017-06-16T13:54:11.600Z
Ben I.
<p>I teach 13-14 year old boys an "Introduction to Computer Science" course.  For most of them, it is their first structured coding experience.</p>

<p>Before we even touch an IDE, I have them walk through problems like this:</p>

<blockquote>
  <p>Devise an algorithm that calculates a user’s paycheque. </p>
  
  <p>The program will begin by welcoming the user.<br>
  It will then ask the user to input their hours worked.<br>
  It will then ask them to input their rate of pay.<br>
  It will then calculate their total pay.  You may assume no deductions due to taxes, fees, dues, etc...
  The program will then exit with an appropriate exit message.</p>
</blockquote>

<p>The correct answer usually looks something like this:</p>

<pre><code>Begin
  print welcome
  input hours
  input rate
  pay = hours * rate
  print pay
  print goodbye
End
</code></pre>

<p>A progression to flowcharts then follows.</p>

<p>I guess what I'm asking the group is "<strong>How do you teach students of this age and ability to think algorithmically?</strong>". I've been teaching C.S. to this age group and ability level for about 15 years or so now.  I find that the problem statement/algorithm/flowchart model is about 95% effective.  I'd estimate that only 5% of the students that I encounter can't break the problem statement/pseudocode barrier. I'm always looking to solve this problem so any constructive criticism this group can offer is greatly appreciated. Even age appropriate resources would be deeply helpful.</p>

CC BY-SA 3.0
2017-06-15T18:06:49.530Z
I don't see how flow charts help. As for as I can see, they are a legacy from before we worked out how to create compilers (This could also be said for pseudo code, however I think that pseudo code is of use when learning your first programming language). Around the time of the first compiler there was a paper “goto considered harmful”, flowcharts are full of `goto`s, and are harmful.
ctrl-alt-delor
CC BY-SA 3.0
2017-06-16T14:12:23.023Z
Maybe the problem isn't so much the logic and structured flow as I hear from reading your comments, but really the parsing and translation of terms for each statement.
Pysis
CC BY-SA 3.0
2017-06-16T16:03:54.820Z
@nocomprende I agree that when teaching low-level programming then flow charts could be useful. I disagree about the 5 things (compare is arithmetic), there for there are 4 thinks (also logic is arithmetic and arithmetic is logic). You could also condense fetch and store into move, now there are only 3 things. This is the von-noumen architecture (harvard as well). There are however other architectures.
ctrl-alt-delor
CC BY-SA 3.0
2017-06-17T03:33:08.770Z
Agreed with other users that using common tasks (sandwich, brushing, etc..) is better.  I use shoe tying.  Yours is too broad a scope.

The site interaction you describe does stuff out of scope from the original description ("Devise an algorithm that calculates a user’s paycheque").  An algorithm is *not* welcome messages and exit messages.  Tying your shoes doesn't include picking shoes to coordinate with your outfit from the closet.  Making a sandwich doesn't mean harvesting the grain to make bread.
Clinton Pierce
CC BY-SA 3.0
2017-06-17T19:32:32.323Z
P.S. on the subject of messages, your problem statement doesn't mention printing the pay but the pseudocode does.
Luke Sawczak
<algorithms><pseudo-code>
How can I help my students to think algorithmically?
# How can I help my students to think algorithmically?

(Asked by: username_0 on 2017-06-15)

I teach 13-14 year old boys an "Introduction to Computer Science" course.  For most of them, it is their first structured coding experience.
Before we even touch an IDE, I have them walk through problems like this:

Devise an algorithm that calculates a user’s paycheque. 
The program will begin by welcoming the user.
  It will then ask the user to input their hours worked.
  It will then ask them to input their rate of pay.
  It will then calculate their total pay.  You may assume no deductions due to taxes, fees, dues, etc...
  The program will then exit with an appropriate exit message.

The correct answer usually looks something like this:
Begin
  print welcome
  input hours
  input rate
  pay = hours * rate
  print pay
  print goodbye
End

A progression to flowcharts then follows.
I guess what I'm asking the group is "How do you teach students of this age and ability to think algorithmically?". I've been teaching C.S. to this age group and ability level for about 15 years or so now.  I find that the problem statement/algorithm/flowchart model is about 95% effective.  I'd estimate that only 5% of the students that I encounter can't break the problem statement/pseudocode barrier. I'm always looking to solve this problem so any constructive criticism this group can offer is greatly appreciated. Even age appropriate resources would be deeply helpful.

**Tags:** algorithms, pseudo-code

> **Comments:**
> **username_1**: I don't see how flow charts help. As for as I can see, they are a legacy from before we worked out how to create compilers (This could also be said for pseudo code, however I think that pseudo code is of use when learning your first programming language). Around the time of the first compiler there was a paper “goto considered harmful”, flowcharts are full of `goto`s, and are harmful.  
> **username_2**: Maybe the problem isn't so much the logic and structured flow as I hear from reading your comments, but really the parsing and translation of terms for each statement.  
> **username_1**: @nocomprende I agree that when teaching low-level programming then flow charts could be useful. I disagree about the 5 things (compare is arithmetic), there for there are 4 thinks (also logic is arithmetic and arithmetic is logic). You could also condense fetch and store into move, now there are only 3 things. This is the von-noumen architecture (harvard as well). There are however other architectures.  
> **username_3**: Agreed with other users that using common tasks (sandwich, brushing, etc..) is better.  I use shoe tying.  Yours is too broad a scope.  The site interaction you describe does stuff out of scope from the original description ("Devise an algorithm that calculates a user’s paycheque").  An algorithm is *not* welcome messages and exit messages.  Tying your shoes doesn't include picking shoes to coordinate with your outfit from the closet.  Making a sandwich doesn't mean harvesting the grain to make bread.  
> **username_4**: P.S. on the subject of messages, your problem statement doesn't mention printing the pay but the pseudocode does.  

---

## 17 answers

### Answer by username_11 on 2017-06-15. Score: 18

Rather than giving them processes to model algorithmically, have them start coming up with algorithms for everyday activities. Here is the formal assignment I have students complete: CS50 AP - Everyday Algorithms.
They begin with a simple pseudocode example:
1   look out the window
2   if it is raining outside
3      put on your rain boots
4      put on your raincoat
5   go outside

After they get comfortable with pseudocode, students write their own simple algorithm:

Okay, now you’ve learned a lot about algorithms and pseudocode.
  Perhaps we should try writing a few—three, to be precise. First, write
  up algorithms (both in sentence form and in pseudocode) for how to:

brush one’s teeth
eat an orange

Next, think of something that you do every day or nearly every day.
  Write an algorithm in sentence form and in pseudocode for how to do
  the thing you’re thinking of.

Students will take more ownership and may understand it new ways if they are coming up with the processes to model based on something important to them. While your example certainly works well, what about students for whom getting a paycheck is unfamiliar territory? You want to use a student's prior knowledge to your advantage, so the focus is solely on the algorithm, not the algorithm and some other idea.
Another essential element I found to getting students to think algorithmically is to model it in all things I do at the start of the year. Everything is a process as follows: input -> algorithm -> output. Let's say I want to take attendance or assign seats. I think out loud with an algorithmic process. My input is an uncounted group of students, and my desired output is a counted group as a means of attendance. Here's the algorithm I use, which I borrow from CS50's first lecture at Yale:
1 stand up and assign yourself the number 1
2 pair off with someone standing, add your numbers together, and adopt the sum as your new number
3 one of the pair should sit down; the other goes back to step 2

The value of this exercise is it gets student moving. Differentiation is essential for teaching students to think in a new way. Get them moving and talking to each other. Make it relevant to their everyday experience.

> **Comments:**
> **username_12**: This is the exact approach my first programming teacher used on my class.  Breaking down "How do you make a peanut-butter and jelly sandwich" in to individual steps is permanently associated with programming for me now.  It was immensely helpful.  

---

### Answer by username_13 on 2017-06-15. Score: 14

> How do you teach students of this age and ability to think algorithmically?

I don't really think there's a silver bullet to this problem. To be able to think algorithmically, **you need to solve lots of problems, over and over**. Some students will naturally have the ability to be able to describe algorithms without much teaching, but it's not a universal skill, and it comes at different rates for different people.

In an ideal world, adapting the level of difficulty of the algorithms to design would be useful: get an easy algorithm right, and then move on to a harder one, until you get stuck, and then go back down until you master algorithm design for even complex problems. However, that would require a lot of attention to do in person, so to get that level of support, you need an automated solution.

I highly recommend [Codewars](https://www.codewars.com/) as a good tool to practice solving simple problems that scale up in difficulty—I had great fun trying some myself a while back.

* A task (kata) is given with instructions, example outputs and (usually) pre-made unit tests.
* You input your solution, test it, then submit. Codewars runs it against (hidden) tests to make sure the solution is valid, and then if so, you gain points.

You can create 'Clans' (perhaps for your class) so a league table is shown—the gamification might be a good motivator for some.

The difficulty of the kata increases as you get better (and harder kata give higher rewards), so the difficulty should ramp up and help students develop their skills.

This, of course, does require students to be relatively comfortable with the *syntax* of at least one programming language. If you've not taught any of the language itself yet, you probably should do that before you teach algorithmic thinking—a basic handle on how a programming language is used would probably be useful so that students can understand what an algorithm can and can't do.

> **Comments:**
> **username_14**: See also: [Code Golf SE](https://codegolf.stackexchange.com/). While I don't expect students to start golfing their code (<shudder>), the sorts of challenges that come up are the ones that are generally good to present. Particularly the ones tagged [kolmogorov-complexity] which is all about expressing something complex as a series of simpler instructions. Algorithms are for finding short cuts by doing the same operation multiple times instead of copy-pasting and why I don't like most of the other answers.  

---

### Answer by username_20 on 2017-06-16. Score: 8

I remember a demonstration from early in my first college CS course (this was in 1998, almost 20 years ago!), where the professor brought in a loaf of bread, a butter knife, a jar of peanut butter, and a jar of jelly. He then asked the class to give him instructions to make a peanut butter sandwich, with predictably hilarious results. After we had finally created the first messy sandwich, he had us repeat the exercise, but this time we had to record the steps on the board in advance. Then he followed the steps, again with hilarious results.

The point, of course, was to first teach us that computer will always take things literally, always do exactly what you tell them, and that mistakes early in the process can cause good instructions later on to have bad results. It's important that *both* the algorithm be correct, and that each instruction that composes the algorithm is correct. It also demonstrated the degree to which we rely on common abstractions and idioms that are often not perfectly represented in the computer.

At the college age, I felt like it was kind of simplistic for us. But for 13-14 year olds this would be perfect.

> **Comments:**
> **username_20**: Please do not remove the parenthetical about the date. The remark isn't just a side-note; it shows that the demo had staying power on impressionable young minds.  
> **username_9**: Quite right, my apologies.  
> **username_7**: I did almost exactly this lesson for years, but I added a computer program into the mix - I created a PB&J simulator, with a syntax and a set of instructions. They had to open and close drawers with their two hands, take out plates, knives, etc... I pasted their "code" into my simulator, and if the end result was a sandwich, they were allowed to actually make it *only following their own instructions*.  There were some peanut-buttery hands in that classroom ;-)  
> **username_15**: I was going to recommend this.  The younger the children the better it works.  However, it's important not to focus too much on funny failures (as is tempting to do) if your doing this to start stressing algorithms in general.  Make sure to try to act like a computer, including simply failing to do anything for some invalid input (rather then doing the wrong thing).  if someone uses poor english syntax give them a syntax error.  if someone tells you something too general tell them you don't now that method/keyword, try to focus on a small set of 'predefined' API calls you understand.  
> **username_15**: Oh, also make sure you ask about peanut allergies ahead of time!!  or maybe just be on the safe side and stick with a jelly sandwich.  

---

### Answer by username_15 on 2017-06-19. Score: 7

Since all the other great answers are all given, let me mention a minor one. [Lateral thinking Puzzles](http://www.folj.com/lateral/) are good for this. They help to teach children to think in a different manner by themselves and encourage general problem solving.

However, they can be used to teach one important part of algorithms, the need for rigor in your statements, if one chooses to go that route. Pick some of the easier lateral thinking puzzles, but threaten to answer questions exactly as a computer will.

You find that many times people ask questions different then they intend to. They phrase things wrong, or they hear one answer but assume you meant something else. If you are very *very* exact in your answering you can make a puzzle hard to solve simply because people interpert your answers very different from what you literally said.

I would also include things like "does not computer" for questions that aren't well phrased, some 'standard' ammusing response to questions that are not yes or no questions. etc. Most importantly, remember in your head some examples where you can see the children misunderstood your answers or made ralse presumptions. Then after a puzzle is solved show them their mistakes and explain to them how they lacked rigour in their questions and how that lead to confusion, it's a good analogy for how you need to approach computers that are 100% literal and do exactly what you told them to, but not always what you meant for them to do.

This works best with "false assumpiton" puzzles that are written in such a way as to trick people into assuming something about the premis that wasn't said. for example:

* use a pronoun to refer to someone who is also refered to by name, so they presume two people are relevant instead of one person refered to in two ways (aliasing!)
* Any puzzle that doesn't use humans as the premise, "Tom killed Jerry but no one cared, why?", because Tom and Jerry are a cat and mouse.
* Trick someone by confusing sex, talk about "Alice and Kris" doing something where people presume Kris is male and the puzzle the mystery is obvious if one realizes Kris is female.
* Other presumptions that are false. Maybe Alice and Kris went out on a date together, they saw a movie and then went out to eat, but after the dinner Kris refused to pay for Alice dinner and left immediately without giving Kris a ride back home. He proceed to complain about how horrible his date was to everyone the next day at school. Alice wasn't upset by any of this, why not?", turns out their both female and on a double date, Alice's dinner and ride home was provided by the boy she was dating and isn't offended that Kris didn't like the boy she dated.

This sort of questions teach the children to learn to check their presumptions and how to ask properly rigorous questions to verify information, even get's them into the mindset needed to debug broken code by knowing what to ask to narrow down a problem.

I've used these sort of things to prepare young kids for the mindset required for programming, but these were kids I was mentoring and spent a bit of time with. It takes a little time to do a puzzle with kids, and while I found they helped me to communicate programming ideas I don't know if they provide so much benefit as to warrant class time spent on them? If nothing else these could be good things to do during 'dead' time, before class officially starts, on the bus during a field trip, while waiting outside during a fire alarm, etc to entertain kids while sneaking in some extra training.


---

### Answer by username_16 on 2017-06-15. Score: 7

The problem as described is simply translation from one firm of words to another, so in some senses, students may not really grasp what you are asking for. I think a more important thing to ask for is to construct algorithms from a less structured problem.

A flow chart is just another way to write the algorithm, not really a progression - and not necessarily useful.

I suspect one major challenge with thinking algorithmically is the ability to break down the problem into the **right number** of steps, with those steps at the **right level** of abstraction. People often tend to focus on either the parts that they know, or the parts that they don't know.

An approach that may help is *successive refinement* where you try to sub-divide the problem in small steps. Inputs and outputs being an obvious thing to try first. The aim is to avoid getting stuck in the minute details, or blocked on a part that you don't know where to begin. Progress on one area will often give some ideas about how to solve another.


---

### Answer by username_21 on 2017-06-17. Score: 7

I'm a bit confused by your question. Your exercise seems to involve some combination of…

1. Requirements gathering: what are the inputs, outputs, and formulas?
2. Translating the requirements to a conceptual model
3. Translating the conceptual model to pseudocode
4. Translating the pseudocode to code
5. Translating the pseudocode or code back to a flowchart (Why? In decades of programming experience, I've almost never found flowcharts to be useful. If anything, they encourage an if-then-goto mentality, which is the opposite of [what you want to aim for](https://mitpress.mit.edu/sicp/).)

It's not clear from your question which parts of the exercise are provided to the students as givens, and which parts you expect the students to perform.

In any case, "Devise an algorithm that calculates a user’s paycheque" is *much* too open-ended a question for a beginner! All of those steps expect students to produce some output starting from a blank slate, which can be intimidating.

Furthermore, I'm not convinced that this exercise teaches useful *computer science* concepts. It may be a useful demonstration of what programmers do, but that's not quite the same thing.

---

As an alternative, I suggest giving exercises where the inputs, outputs, and expected behaviour are obvious. The correctness of the response should be easily testable.

For kids, you could try [Code Combat](https://codecombat.com) or [Code.org's exercises](https://code.org/learn). Some of the exercises can be done in visual programming environments using drag-and-drop blocks (like [Scratch](https://scratch.mit.edu) or [Snap](https://snap.berkeley.edu)), eliminating the fear that some students encounter when asked to write something starting with an empty screen. If you're looking for more "traditional" programming environments, you could try [Karel](https://en.wikipedia.org/wiki/Karel_%28programming_language%29) exercises, which have been ported to a variety of programming languages. These exercises all encourage students to develop algorithms — mainly to move characters on a board in a specified pattern. In contrast to your open-ended exercise, these are highly guided activities, which gradually increase in difficulty.

Once students have mastered the concept of developing algorithms to solve problems with extremely well specified inputs and outputs, then they can be asked to apply those ideas to real-life problems, where the inputs are not fixed, the scope is unclear, and requirements are negotiable.

> **Comments:**
> **username_7**: This is a beautiful answer. Very well thought out. Welcome to CSE! I hope we hear more from you.  

---

### Answer by username_22 on 2017-06-15. Score: 7

Thinking algorithmically isn't always natural. In an algorithm, you're going to write down everything the computer is going to, then hit "go" and step away for a few microseconds while the computer does it. In most of our lives, there's more back-and-forth in our interactions, so it takes a while to get used to thinking in this one-pass approach.

Something I think would be helpful is an origami game. It's *really* hard, but an excellent introduction to thinking like this. The game works like this:

1. Teams are split into two groups (minimum team size of 2, obviously)
2. One group is given a folded origami creation and pictoral instructions on how to make it.
3. That group must create *written* (not pictural) instructions to make the object.
4. Those instructions are then given to the second half of the team, who have to create the orgami from those instructions. They do not get to see the pictorial instructions nor what the final product should look like.

A few rounds through that will quickly teach them what works and what doesn't.

It also makes you *really* appreciate your debugger!


---

### Answer by username_17 on 2017-06-16. Score: 6

Sounds like you've tried everything already, but here are some suggestions:

* Use a scenario / problem that every student can relate to

  > Most of my lower ability 13-14 year old boys don't have much experience of wages, tax and jobs. Writing an algorithm for making a perfect cup of tea doesn't do much for them either. Drawing a flow chart for **how to irritate a teacher** and comparing it to **how to get a merit / positive / reward / whatever the equivalent in your school** is always a memorable lesson.
* Give them lots of practice at understanding pseudocode before asking them to write it

  > Getting students to physically act out instructions can be time consuming and patronising but can also be really helpful for students struggling to visualise the sequence. Getting students to take turns giving instructions to sort numbers (bits of paper stuck to a wall) is a good way of doing this. Alternatively, you can set some challenges [like this](http://tools.withcode.uk/ks4pseudo/) so students can work through the process of following instructions, ideally with instant feedback if they get each one right.
* Give them broken algorithms to fix

  > This works really nicely as a team activity. First, students work in pairs to diagnose and fix problems in algorithms you give them and then they design algorithms for each other with some obvious mistakes. The mistakes could be using the wrong symbols in a flowchart (leading to a discussion about syntax errors), writing a statement that doesn't really make sense (leading to a discussion about needing crystal clear, unambiguous instructions) or writing an instruction that's just plain wrong (leading to a discussion about logical errors)


---

### Answer by username_18 on 2017-06-16. Score: 5

* One thing that helps in my experience (albeit with older students) is to give a pseudo-code cheat-sheet and insist that the problem has to be solved only using the building blocks on the sheet. In particular, you must insist that anything that is not on the list must be written using the building blocks.

  So if at some point they need to fill an array with something, there is no magical "fill the array" step. The students have to first define it in terms of increment, for loops, or whatever you have in the pseudo-language. And that is the hard part. What do you allow in your pseudo-code? Side effects? Functions vs Procedure? By-value, and by-reference parameter passing? It all depends.
* One way to reach the point where you can actually write pseudo-code, is to start from slightly more general problem statements, then refine it in smaller steps, and then again, until you arrive toward something that is pseudo-code. In your example I would start the exercise by asking just **"Devise an algorithm that calculates a user’s paycheque based on the hourly rate and the number of hours."**

  I would let the student work collectively while guiding them and only let them do the actual last step (English -> pseudo-code) individually. And gradually help them less and less. For instance a student might say "oh you multiply early rate by number of hours and done". Yes but where do you get the rate and hours from? *"Huh? Maybe I need to read them from somewhere or ask the user"*. And what do you do with the result ? *"Oh yes
  that's right I have to display it"* etc... And then when you have all the bits, put them in order and express them using pseudo-language.


---

### Answer by username_19 on 2017-06-17. Score: 5

I just finished up 8th grade.

I took an Intro to Engineering/Robotics class as an elective this past semester. I have programmed (mainly in Python 3) before this class, and I was mainly excited for the Robotics part. When we started, the teacher talked to us about how the computer takes things very literally, etc, etc, and then - he had us pretend he was the robot. So he told us to "program" him to get to the door. Someone forgot to tell him to turn, so he literally walked into a wall. Another person got him too close to the door, so when someone else told him to lift up his arm - hit the door. So he walked us through that.

Then he gave us very simple exercises - turn the motor on at such and such speed for this time, and then stop it, and had us write out the pseudo code, check it with him, and then turn it into regular code, and so on. As the problems got more complex, the pseudo code got more and more important. One problem, the full solution's code was much more complex, and so he had most people do it an easier way, but he let me try the full solution, so I worked on it, and he had me diagram a part up on the whiteboard for him, and so on, and it worked.

I guess the point is, give an illustration - like the PB&J one that seems to be popular, or this one, and then emphasize pseudocode as they solve simple problems, and eventually, as the problems get more complex, it will serve them well. The key is to have them do tons of programming, and eventually it will come more naturally.

Another idea is to do a form of code golf - have people come up with solutions, pick a slower/longer solution, and encourage ideas to make it more efficient, and so on, until you have a much more ideal piece of code.

> **Comments:**
> **username_7**: Welcome to CSE! You are very articulate young lady. I hope we hear more from you as you continue to learn about computer science. :)  

---

### Answer by username_23 on 2017-06-27. Score: 4

The biggest problem is moving students to a difficult algorithm before they have mileage with simple ones.
The best way I've found is

a. Go over the classic small algorithms, especially array and string based.
- e.g. find the sum, min, max, do a swap.

b. give students many small algorithmic problems to solve. I use the exercises at codingbat.com which were written Nick Parlante, a lecturer at Stanford. I give a lot of level 1 problems, and can usually get them to level 2 near the end of the semester.

Another thing I do is, every lab has a prelab consisting of a bunch of code interspersed with print statements, asking "What does this code print?" I believe that tracing code strengthens students' algorithmic thinking as well.

Finally, homework assignments before the lab with code tracing and writing code snippets also help students a lot.


---

### Answer by username_9 on 2017-06-16. Score: 4

Even though it can be complicated, recursion gives a great algorithmic view of problems. I have seen quite a few students start to think in an algorithmic way after I introduce recursion (just very simple problems such as printing the individual characters of a string. I'll refer to this exercise as an example task throughout the answer).

This gives them the basic idea of what thinking in an algorithmic way means. I go with them every step of the way, and make sure that they all understand exactly what's going on.

Then, I go on to saying that the core of algorithmic thinking is breaking a problem into smaller problems that are very similar to one another (sort of like doing an operation on a tree; you preform on a node, and then on it's children, and so on).

Usually I find it useful to have a classroom discussion on how one deals with big problems/tasks. I lead them to the conclusion that they need to break it into smaller problems, conceptually, before they can write a code that tackles the big problems. This gets the notion of treating problems as a collection of easy tasks that are solved one at a time in a similar manner.

After saying this, I remind them the small recursive task from the beginning. All the program does is print the first letter of the given string. That's easy to the point of ridiculous.

This way, the students understand that algorithmic thinking is just breaking a problem into smaller problems that they know how to solve. A part of algorithmic thinking is turning the input into a form or structure that they can handle in an easy way. This is shown in the example task by turning a string, which is a bit more complex than a single character, into a single character. This is the process of simplification of the problem, which is essential in algorithmic thinking.

From students' feedback, this method works very well. In fact some students start searching (pun intended) for search algorithms and they quickly find and use alpha-beta pruning, minmax and others. They really get the idea of thinking algorithmically.

> **Comments:**
> **username_9**: @nocomprende that's really non constructive for the students  

---

### Answer by username_7 on 2017-06-15. Score: 4

So far in my career, when I have a student who just *doesn't seem to get it* (and there is no obvious discernible cause) it very often comes down to one of two problems.

The first is **mutability**, which I wrote a little piece about [here](https://cseducators.stackexchange.com/a/345/27). Kids who can't easily trace how values will change need explicit practice in this concept before they will really be able to follow what is going on in imperative languages, and it can take a surprising amount of practice to help them to really *get* it. The fact that it's so easy to describe is disarming, because we think they get it. And the kind of extremely simple code that we might use to determine understanding often doesn't trigger the kinds of incorrect responses that would naturally call teachers to action. However, as soon as the code itself starts gaining any complexity, having a cloudy notion of mutability is a game-stopper, pure and simple.

The second is **simple motivation**. For the kids who aren't so quick with CS at the start, not being willing to put extra thought and effort into the topic halts their growth. I don't have a lot of generalized insight into how to fix this one. When I have unmotivated kids, they mostly just kind of muddle through.

> **Comments:**
> **username_7**: It's the right question, and I agree with you. I try to give free choice in labs when I can, but sometimes kids stick with it past add/drop, and then you are all stuck with each other.  

---

### Answer by username_5 on 2017-06-18. Score: 2

1. Practice. Thinking algorithmically is a skill, and skills develop with focused practice over time. All of the relevant-to-life examples in previous answers are forms of practice that will result in some skills transfer to computer algorithms and also maintain student interest. You could add some basic mathematical algorithms that students know to the pool of practice exercises. Work through the algorithms for addition and subtraction and translate them into pseudocode. Something like "sort a deck of cards" is perhaps an ideal example because sorting is something that people sometimes do in real life and also something that we actually program computers to do (unlike "make a PB&J" or "perform addition in base 10").

   Practice exercises should be assessed by the teacher and used to help identify areas where students are having conceptual difficulties with the material.

   You can also give students a simple algorithm for debugging their code, which both reinforces algorithm following and also teaches the separate valuable skill of debugging their code. Steps could include "read the error message", "check for syntax errors", "google the error message", "explain your problem out loud to a rubber duck", etc.
2. Teach subskills. "Thinking algorithmically" is a huge skill with many subskills. Break algorithmic thinking into its subskills and teach them individually:

   * Identify inputs and outputs.
   * Identify repetition/repeatable steps.
   * Identify success and failure conditions.
   * Identify problems that lend themselves to an algorithmic solution and reframe problems in ways that clarify what the algorithm needs to do.
   * Select and employ an algorithmic strategy to attempt to solve a problem.
   * Test potential solutions on a number of datasets.

   Learning and practicing these subskills explicitly will help to ensure that students are thinking and communicating very clearly about the problems they are trying to solve an the methods they are trying to use. This clear thought and communication is really the only way that students have a hope of understanding more complicated and abstract problems and solutions.
3. Teach strategies. Iteration and recursion, divide-and-conquer, dynamic programming, greedy algorithms. I found a [power point presentation](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwiyx57emcfUAhUGvhQKHaOxDSwQFgg4MAM&url=https%3A%2F%2Fwww.cis.upenn.edu%2F~matuszek%2Fcit594-2007%2FLectures%2F27-algorithm-types.ppt&usg=AFQjCNGRn6TenIDttsYL66V6Wq2nAFKHlQ&sig2=KjcKY08LIswt7q8c72Y4Og) with some basic algorithm types and simple examples that demonstrate those types, many of which could be adapted for students at that age level. For example, the four-color map algorithm could actually be done by students on paper, and can be a lot of fun (I've used the four-color theorem in lessons before and the kids loved it); the counting money algorithm (make a certain amount of money with the least number of coins and bills) could also be very accessible and relevant for students.


---

### Answer by username_6 on 2017-06-16. Score: 2

Do you know about the initiative called Scratch?

It's a visual and algorithmical language, it can be useful as an introductory subject for your students.

In scratch you can visually build loops, conditionals, functions, and return events, it's a whole language that is more approachable to beginners, and maybe might incite more their inquisitive nature.

It helps by literally making them shape visually an algorithm or program, they could also share it with fellow students and get other's code from the community, it also has some fun features such as running a loop to play sounds or images.

It's also used briefly in **CS50: Introduction to Computer Science** from Harvard.

You might want to give it a try, it could help your students, especially since they are so young.

> **Comments:**
> **username_7**: Welcome to CSE!  We're very glad to have you here.  This answer needs a little work, though. How will this help OP's students to think algorithmically?  
> **username_6**: In scratch you can visually build loops, conditionals, functions, and return events, it's a whole language that is more approachable to beginners, and maybe might incite more their inquisitive nature.  It helps by literally making them shape visually an algorithm or program, they could also share it with fellow students and get other "code" from the community, it also has some fun features such as running a loop to play sounds or images.  
> **username_7**: Good improvements.  Keeping the quality of the questions and answers high here is a really big deal, because it's what makes the whole enterprise worthwhile.  I hope to keep seeing you around the site!  

---

### Answer by username_8 on 2017-06-17. Score: 2

[Here's an enlightening blog post](http://blog.karhatsu.com/2014/09/experiences-from-programming-with-kids.html) about teaching programming to elementary school age children. They started without any computers at all by "programming" the teacher to walk from one corner of the class to the other using few simple commands. They then proceeded to use the [Turtle Roy](http://turtle-roy.herokuapp.com/) online programming environment which works like the [Logo programming language](https://en.wikipedia.org/wiki/Logo_(programming_language)) and teaches you to think algorithmically, with visual results that are immediately visible.

> **Comments:**
> **username_9**: This is a good answer, but if you can add details about how Turtle Roy teaches you to think algorithmically, it would really make this into a great answer.  
> **username_7**: Also, welcome to CSE!  

---

### Answer by username_10 on 2017-06-17. Score: 0

Algorithmic thinking can perhaps best be taught completely apart from coding in the classes given programming language(s).

I might have one student tell another student how to solve a fairly easy problem on a whiteboard, but only communicating one step at a time using a constrained set of commands, for instance only one input, one arithmetic operation step, or one saved result at a time. Maybe have the algorithm developer write out the steps while the operator student is out of the room, them have the operator come back into the room and execute the written algorithm on the whiteboard.

One example might be averaging N numbers, where student A writes an algorithm, student B later provides the numbers one at a time, then student C uses the algorithm to compute a result, while the class watches.


---

