Could you sort them into ascending order?
Sure you could -- it was easy. But, how did you do it? Could you write down the steps you followed? Could you write them so carefully that someone else could follow them and get the same result? Could you write them so carefully that a computer could follow them and get the same result? Such a list of steps would be called an algorithm.
This is the algorithm I used in sorting the cards into ascending order:
We have been speaking of an algorithm for sorting numbers, but one can think of algorithms for all sorts of things. Could you write a list of steps for baking a chocolate cake or for getting up and getting ready to go to school or work in the morning?
One approach to designing an algorithm is to solve a problem yourself, while paying careful attention to how you do it. Instead of just sorting the cards in one step, introspect -- think about what you are doing as you do it, and write the steps down as you work. If you are making a cake, write each step as you complete it.
Do not try to write the steps in VB. Write them in English, using common sense vocabulary as I have done above. Once you understand the procedure you have been using to solve sample problems well enough to write the steps in English, you can translate them into VB.
Working through a problem yourself, and thinking about what you are doing, often helps in figuring out what exactly you want to tell the computer to do when an event occurs. Programming involves inventing procedures for the computer to follow, and a programmer must learn to think procedurally.
When you write down the steps of an algorithm in common-sense English, you are writing pseudo code. Once you have written and understand your pseudo code, you can code it in VB or a different programming language.
The term "algorithm" is derived from the name of the mathematician Abu Ja'far Muhammad ibn Musa Al-Khwarizm who lived in Baghdad in the ninth century. He is credited with the invention of algebra, also named for him, and the idea that math problems could be solved by a series of steps. |