Skip to main content
27 votes
Accepted

How to respond to the two-handed approach to swapping

Don't overcomplicate things. Your first instinct, that the computer only has one hand, was the correct one. This is a regular problem that new teachers have, and it sometimes takes a few years of ...
Ben I.'s user avatar
  • 33.7k
22 votes

How to respond to the two-handed approach to swapping

Re-evaluate what you think is "right", because you aren't but isn't right in computer science This is simply incorrect. Your student can create two variables called ...
Graham's user avatar
  • 1,072
17 votes

How to respond to the two-handed approach to swapping

Your problem is that you tried to let your student "program" without establishing a language. Thus they were free to write their own "language" in which you can do two things at ...
Victor Eijkhout's user avatar
10 votes

When should concurrency and parallel multi-processing concepts be introduced?

If we don't introduce parallel/concurrent thinking early, our students can develop a sequential mindset that makes it hard for them to make the shift later. The rest of this is in the context of a ...
Joel Adams's user avatar
  • 1,011
9 votes
Accepted

Why is the critical-section problem always presented with code in infinite loops?

One reason infinite loops are used could be so the problem can't be solved by letting one thread complete the code before the other thread starts it. With infinite loops, no thread ever completes the ...
Ellen Spertus's user avatar
5 votes

How to respond to the two-handed approach to swapping

This question reminds me of when a student failed to understand why a third variable was needed to exchange the value of two variables (i.e. to swap A and B, C=A, A=B, B=C). I managed to illustrate ...
Kaz's user avatar
  • 151
5 votes

How to respond to the two-handed approach to swapping

They took both their hands, picked up the second and fourth pencils (each in one hand), and swapped them! That works in reality... but isn't right in computer science. It depends on your paradigm. ...
Jason Goemaat's user avatar
5 votes

When should concurrency and parallel multi-processing concepts be introduced?

We're introducing some aspects of parallel processing quite early on in Scratch. Each sprite has its own script which appears to execute in parallel with those of the others. Scratch has a broadcast ...
Miles's user avatar
  • 1,266
5 votes

Why is the critical-section problem always presented with code in infinite loops?

"processes that run and enter critical sections ... where the code is not in an infinite loop" Processes are generally components of a reactive system (like an OS) that are designed to be non-...
Moti's user avatar
  • 111
4 votes

Could you recommend books on concurrent programming?

Concurrent programming is easy, synchronisation is hard. Have a look at this video for an alternative to synchronisation: https://www.youtube.com/watch?v=2yXtZ8x7TXw When you have to synchronize Use ...
ctrl-alt-delor's user avatar
3 votes

Could you recommend books on concurrent programming?

Since the OP asked about functional programming, so I would highly recommend you to read "Learning Concurrent Programming in Scala" by Aleksandar Prokopec, (2014). All the examples for this book are ...
Failed Scientist's user avatar
3 votes

How to respond to the two-handed approach to swapping

I do the swap example pretending to have two largish (2-hands-to-lift) boxes side-by-side on a desk (with only enough room for two boxes). After we lift the first we have to look for a place to put it,...
Owen Reynolds's user avatar
3 votes

How to respond to the two-handed approach to swapping

In thinking about this, and especially the answer of Graham, I think that what we really do in the standard three step process is a two handed swap without thinking of it. So, it is a failure of the ...
Buffy's user avatar
  • 36.4k
3 votes

How to respond to the two-handed approach to swapping

Analogies & metaphors are imperfect, so let's share the expectation that they are just illustrative. Rules of what is possible (and not) are very important, and we can compare the rules of pencils ...
Erik Eidt's user avatar
  • 333
2 votes

How to respond to the two-handed approach to swapping

Graham pointed out that the assumtions of the question are wrong. And Peter Cordes elaborated a bit in the comments. Considering a target VLIW (Very Long Instruction Word) architecture can help ...
Rushi's user avatar
  • 948
2 votes

How to respond to the two-handed approach to swapping

Ben's answer is great, but allow me to suggest that you don't need to "respond" to the two-handed approach at all: just say when you're explaining the problem in the first place that they ...
kaya3's user avatar
  • 529
2 votes

Could you recommend books on concurrent programming?

The Well Grounded Java Developer has an excellent section on concurrency. The author claims that very few developers correctly implement concurrency. As ctrl-alt-delor put it: concurrency is easy; ...
Thorn's user avatar
  • 272
2 votes

Could you recommend books on concurrent programming?

I have no recommendations for the theory part but since you are asking for implementation advice as well, here we go. If you are looking to use C sharp (you haven't specified a specific language of ...
Jay's user avatar
  • 1,884
2 votes

When should concurrency and parallel multi-processing concepts be introduced?

I do not see much value in teaching more than an appreciation of threads and locking, until you have covered less primitive techniques for parallelism. These techniques allow parallelism that scales ...
ctrl-alt-delor's user avatar
2 votes

When should concurrency and parallel multi-processing concepts be introduced?

In UK at A-level We cover the following. Multi-core, semaphores, queues, process pipeline, SISD, MISD, SIMD, MIMD. We don't specifically cover how to write programs using these. A student could ...
ctrl-alt-delor's user avatar
2 votes

When should concurrency and parallel multi-processing concepts be introduced?

Given the type of software development that occurs these days, such as on mobile phones and with "big data" technologies, I think concurrency, threading, etc. should be introduced very early. ...
Uncle Long Hair's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible