Shortcut to seniority
Home
Go to main page
Section level: Junior
A journey into the programming realm
Section level: Intermediate
The point of no return
Section level: Senior
Leaping into the unknown
                    Go to main page
A journey into the programming realm
The point of no return
Leaping into the unknown
Computers are everywhere. We are surrounded by technology, whether be it on our phones / tablets, in our cars, or on our laptops. But what is a computer and how does it work?
In the beginning, computers started as common calculators, and they were only manipulating numbers back then.
It all started when humans began wondering whether a machine could be designed to help us with the thinking we do, such as solving equations. In order to do so, the machines needed to manipulate information.
Therefore, a computer is a machine that is able to perform the following tasks:
We tell the computer what to do through the input, which is performed by using the keyboard, mouse, microphone, camera, touch screen, etc. All the input is stored as information in the memory of the computer.
A computer’s processor takes information from memory, manipulates it, and then it sends the processed information back to the memory, in order to be stored.
The output is what we see, as the end users of the computer. It can be either by text, image, videos, etc. When two computers are connected via internet, the output of one can be passed as input to another, and so on.
A computer is made out of hardware pieces, and the most important ones are the following:
The motherboard connects all the computer parts together, either directly, or via cables.
The CPU is the brain of the computer, being responsible for processing commands from hardware and software.
The CPU clock speed of a processor is the number of instructions that can be processed each second. A CPU with a clock speed of 3.0 GHz can process 3.0 billion instructions (CPU cycles) per second.
CPUs with multiple cores (dual core, quad-core) means that the CPU can simultaneously manage two/four times the number of instructions every second.
CPU registers are a place to temporarily store commonly used data. Registers are the fastest possible access to the processor, but they are very limited in size.
Similar to the CPU registers, CPU cache is a place to temporarily store commonly used data, for faster retrieval. The data in cache is slower than accessing the registers, but faster than using RAM because it's a physical part of the processor.
RAM is the hardware which temporarily stores data. When data is used, it is first fetched from storage (hard drive) into RAM, because it is much quicker to run the data from the RAM. As an analogy, the RAM is similar to a desk in which all the files that you’re using are there, while all the files you have ever had are stored in a storage place far from you. In comparison with the hard drive, the contents in RAM are lost when the power is off, whereas on hard drive the data is persistent, hence the term of storage.
                                            If we want to know how computers work on the inside, we need to talk about electric wires, circuits, and signals.
                                            Inside the computer, we will find electric wires and circuits that carry all the information, and that uses electricity to do their job.
                                        
But how can they do so?
If you have a single wire with electricity flowing through it, the signal can be either on or off. This is great, because one wire can now represent the value one or zero, based on the electricity state.
This state of a wire is called a bit, and this is the smallest unit of information a computer can store.
In order to process the information received as input, and to provide output to the end-user, a computer needs the input signals. This is performed with the use of the electronic components, which come together to form circuits.
The “NOT” circuit takes an electrical signal and flips it. If the input is 1, the circuit sends a 0, otherwise it will send 1. Since the signal that comes in is NOT the same as the signal that comes out, the signal is called "NOT".
| Input | Result | 
|---|---|
| 0 | 1 | 
| 1 | 0 | 
Other circuits take multiple signals and combine them.
The AND gate returns 1 only if both input signals are 1, otherwise the output will be 0.
| Input 1 | Input 2 | Result | 
|---|---|---|
| 0 | 0 | 0 | 
| 0 | 1 | 0 | 
| 1 | 0 | 0 | 
| 1 | 1 | 1 | 
The OR gate returns 1 if either of the input signals is 1. The result will be 0 only if both signals are 0.
| Input 1 | Input 2 | Result | 
|---|---|---|
| 0 | 0 | 0 | 
| 0 | 1 | 1 | 
| 1 | 0 | 1 | 
| 1 | 1 | 1 | 
The XOR gate returns 1 if only one of the two signals are 1. The result will be 0 if both signals are equal. (both 0 or 1)
| Input 1 | Input 2 | Result | 
|---|---|---|
| 0 | 0 | 0 | 
| 0 | 1 | 1 | 
| 1 | 0 | 1 | 
| 1 | 1 | 0 | 
These gates perform simple calculations, but when put together in a circuit, they are able to perform more complicated calculations.
An Adder is a circuit board that adds two bits together. This circuit takes two bits, and adds them together to calculate the sum.
| Input 1 | Input 2 | Result | 
|---|---|---|
| 0 | 0 | 00 | 
| 0 | 1 | 01 | 
| 1 | 0 | 01 | 
| 1 | 1 | 10 | 
Putting circuits side by side can be further used to calculate the sum of much larger numbers.
An example of platform is the operating system, so we can include windows-related code only if we’re building the binary for windows, for example.
A pointer references a location in memory.
CPU cache is a small storage space that keeps the most frequently used data in order to reduce the accesses to the main memory.
Except for languages that contain garbage collector (which automatically frees memory that is no longer referenced).
NULL refer to the absence of a value, which means that it is not the same as having the value 0.
A Complete binary tree is a binary tree in which all nodes except leaves have two children, and the last level has all keys as left as possible.