In my last post, I alluded to the topic of this post. Sorry about that. I usually like to lay the groundwork and build on it, but I got a bit carried away. In best practice, we should avoid leaning on information we have not yet provided.
Static and Dynamic
Before we can discuss the clock,
In simple terms, a program is a series of instructions to be executed in a particular order. The program execution cycle is a method by which we attempt to improve the speed of this execution series.
We have previously discussed the concept of the clock, which is used to coordinate all operations in a
We have already discussed the fact that a program is a series of instructions executed in a particular order. This is mostly correct, but it's a bit more complicated than that.
When we know that we already have all the data we need to execute our program, we can just run it in one
As we learned earlier, programs are broken into assembly instructions, which are executed one-at-a-time. The question which naturally arises is what constitutes an instruction, and how many instructions we actually need.
There are two major categories of instruction sets:
The Reduced Instruction Set Computer (RISC) has a very small set of very basic instructions. These instructions
Programs are essentially computer recipes - a series of steps and ingredients (variables) which produces a result. However, when dealing with large problems, we have to create larger and larger recipes. This is why we break down individual solutions into processes we call algorithms.
Algorithm - An Overview
An algorithm is a step-by-step solution to a
A few fun algorithms, all of which are patently slow.
Bogosort - Theoretically, if we randomly shuffle the elements in our list, they will eventually be sorted.
while(LIST not sorted)
Bogobogosort - This is a slower bogosort, if you can believe it. Every time we fail to sort part of the list, we start over at the
Programs are composed of algorithms - recipes for completing simple tasks. The steps used to compose an algorithm can be classified into sequences and decisions.
Sequences and Decisions
A sequence of instructions is a step-by-step flow, with only one possible path. These are the meat of the code, as these do the heavy lifting.
A decision is
Many problems in this world require us to perform a series of steps over and over, looking for the correct result. In computer programming, we have three ways to do this.
Keep it Simple
Of course, if you really want to make this easy for yourself, you just write the solution as one big block. This
Programming makes our lives easier, but most people don't fully understand how much easier.
Programming began with gears
That's right, folks. Long ago, when you wanted to do math quickly, you had to use something like an abacus or slide rule. Sure, you had geniuses like Babbage with his mechanical adding machine, but these were very
Programs go through a variety of stages on the way to execution. Depending on the type of language, some steps may be added or removed to the list, but here are the stages for a compiled language like C.
All programs start with a problem which needs to be solved. This problem could be as