Algorithm Cheat Sheet
Quick reference for the fundamentals of algorithmic thinking.
🎯 Key Differences at a Glance
| Concept | Definition | Format | Best For |
|---|---|---|---|
| Algorithm | Step-by-step problem-solving procedure | Plain English, math, diagrams | Planning and understanding logic |
| Pseudocode | Structured code-like notation | Text with programming keywords | Writing before actual coding |
| Flowchart | Visual diagram of algorithm flow | Shapes and arrows | Visualizing complex decisions |
📝 Algorithm Properties
Every valid algorithm must have:
- ✅ Finite - Must terminate after a finite number of steps
- ✅ Definite - Each step must be precise and unambiguous
- ✅ Input - Takes zero or more inputs
- ✅ Output - Produces at least one output
- ✅ Effective - Each operation must be doable in finite time
🔤 Pseudocode Keywords
| Keyword | Usage | Example |
|---|---|---|
BEGIN | Start of algorithm | BEGIN CalculateSum |
END | End of algorithm | END |
INPUT | Accept user input | INPUT number |
OUTPUT/PRINT | Display result | PRINT result |
IF/THEN/ELSE | Conditional logic | IF x > 0 THEN |
FOR/DO | Counted loop | FOR i FROM 1 TO 10 DO |
WHILE/DO | Conditional loop | WHILE x > 0 DO |
REPEAT/UNTIL | Post-test loop | REPEAT ... UNTIL x = 0 |
RETURN | Return value | RETURN result |
🎨 Flowchart Symbols
| Symbol | Name | Purpose |
|---|---|---|
| Oval | Start/End points | |
| Rectangle | Process/Action | |
| Diamond | Decision (Yes/No) | |
| Parallelogram | Input/Output | |
| Arrow | Flow direction |
🔄 Common Patterns
Sequence Pattern
Step 1
Step 2
Step 3
Selection Pattern (IF-THEN-ELSE)
IF condition THEN
action1
ELSE
action2
END IF
Repetition Pattern (LOOP)
WHILE condition DO
action
END WHILE
📊 Quick Decision Guide
| Situation | Use This |
|---|---|
| Planning a new program | Start with Algorithm |
| Teaching someone logic | Use Pseudocode |
| Complex decision logic | Draw Flowchart |
| Ready to code | Convert Pseudocode to actual code |
| Debugging logic | Review Flowchart |
💡 Memory Tricks
- Algorithm = A Logical Guide Of Rules In Timesteps Having Meaning
- Pseudocode = Pretend Structured English Using Decorated Operations Code Of Developers Expressed
- Flowchart = Follow Logical Operations With Chart Hierarchy And Reviewable Trails
🚦 Best Practices
Writing Algorithms
✅ Use clear, simple language
✅ Number steps sequentially
✅ Handle edge cases
❌ Avoid ambiguous terms
❌ Don't skip steps
Writing Pseudocode
✅ Use consistent indentation
✅ One statement per line
✅ Include meaningful variable names
❌ Don't use language-specific syntax
❌ Avoid complex nesting
Drawing Flowcharts
✅ Use standard symbols consistently
✅ Keep flow top-to-bottom, left-to-right
✅ Label decision branches clearly
❌ Don't cross lines unnecessarily
❌ Avoid overcrowding
🔗 Related Concepts
- Variables & Data Types - storing data in algorithms
- Conditionals - implementing IF-THEN-ELSE logic
- Loops - implementing repetition patterns
- Functions - organizing algorithms into reusable blocks
📱 Quick Reference Card
ALGORITHM → The PLAN (what to do)
PSEUDOCODE → The BLUEPRINT (how to write it)
FLOWCHART → The MAP (how it looks)
Remember
Master these three forms, and you'll be able to tackle any programming problem!