Computer Fundamentals
Memory Hierarchy
Memory hierarchy is organized based on speed, cost, and capacity. Faster memory is more expensive and has less storage, while slower memory is cheaper with more capacity.
Analogy: Think of it like a library: Your desk (registers) holds books you're reading right now, a nearby shelf (cache) has books you might need soon, the main library (RAM) has all available books, and archives (HDD/SSD) store rarely accessed books.
Registers
Fastest (1 cycle), smallest, inside CPU. Stores immediate data being processed.
Cache (L1, L2, L3)
Very fast (2-10 cycles), small (KB-MB). Stores frequently used data.
RAM (Main Memory)
Fast (100+ cycles), medium size (GB). Volatile - data lost when powered off.
Secondary Storage (HDD/SSD)
Slower, large (TB). Non-volatile - data persists after power off.
Types of Software
Software is divided into two main categories based on their purpose and how they interact with hardware.
System Software
Acts as a bridge between hardware and application software. Manages and controls computer hardware.
- OS: Windows, Linux, macOS - Manages resources
- Compilers: Translates high-level code to machine code
- Device Drivers: Controls hardware devices
Application Software
Designed for end-users to perform specific tasks. Works on top of system software.
- Productivity: Word, Excel, PowerPoint
- Browsers: Chrome, Firefox - Access the internet
- Media: VLC, Photoshop - Entertainment & editing
Binary Number System
Computers use binary (base-2) - only 0s and 1s - because digital circuits have two states: ON (1) and OFF (0). Everything in a computer, from numbers to text to images, is stored as binary.
Key Point: Each binary digit is called a bit. 8 bits = 1 byte. For example: 11010101 is 1 byte (8 bits).
Understanding Decimal to Binary Conversion
To convert decimal to binary, repeatedly divide by 2 and collect remainders from bottom to top.
Example: Convert 13 to binary
Understanding Binary to Decimal Conversion
Each position has a power of 2. Multiply each bit by its position value and add them up.
Example: Convert 1101 to decimal
Signed Bit Notation (Sign-and-Magnitude)
In signed bit notation (also called sign-and-magnitude), the leftmost bit represents the sign (0 = positive, 1 = negative), and the remaining bits represent the magnitude (absolute value).
How It Works
Advantages
- Simple and intuitive to understand
- Easy to determine sign (just check MSB)
- Symmetric range for positive/negative
Disadvantages
- Two representations of zero (+0 and -0)
- Arithmetic operations more complex
- Not commonly used in modern computers
2's Complement
2's complement is the most common method for representing signed numbers in computers. The leftmost bit (MSB - Most Significant Bit) is the sign bit: 0 = positive, 1 = negative. Unlike signed bit notation, it has only one representation of zero and makes arithmetic operations simpler.
Finding 2's Complement
- Write binary of positive number
- 1's complement: Flip all bits (0→1, 1→0)
- 2's complement: Add 1 to 1's complement
Example: -5 in 8-bit
Examples (8-bit numbers)
Range for 8-bit signed: -128 to +127 (MSB is sign bit)
Advantages
- Only one representation of zero
- Simpler arithmetic circuits (addition/subtraction)
- Standard in modern computer systems
- Efficient for hardware implementation
Disadvantages
- Asymmetric range (one more negative)
- Less intuitive than sign-and-magnitude
- Converting to negative requires bit manipulation
Comparison: Signed Bit vs 2's Complement
| Binary (8-bit) | Signed Bit | 2's Complement |
|---|---|---|
| 01111111 | +127 | +127 |
| 00000001 | +1 | +1 |
| 00000000 | +0 | 0 |
| 10000000 | -0 | -128 |
| 10000001 | -1 | -127 |
| 11111111 | -127 | -1 |
- • Range: -127 to +127
- • Two representations of zero
- • Symmetric range
- • Range: -128 to +127
- • One representation of zero
- • Asymmetric range (one extra negative)
Algorithm & Flowchart
An algorithm is a step-by-step procedure to solve a problem. It's like a recipe - clear instructions that anyone can follow to get the same result.
A flowchart is a visual representation of an algorithm using symbols.
Algorithm Properties
- Finite: Must end after a finite number of steps
- Definite: Each step must be clear and unambiguous
- Input: Can have zero or more inputs
- Output: Must produce at least one output
Flowchart Symbols
- Oval: Start/End
- Rectangle: Process/Action
- Diamond: Decision/Condition
- Parallelogram: Input/Output