### **Introduction to Computer Science – Study Notes**
#### **1. What is Computer Science?**
- **Definition:** The study of computation, algorithms, data structures, and the design of
software/hardware systems.
- **Key Areas:**
- **Algorithms & Problem-Solving** (efficiency, correctness)
- **Programming** (writing code to execute tasks)
- **Data Structures** (organizing and storing data)
- **Computer Architecture** (how hardware works)
- **Theory of Computation** (what problems can computers solve?)
---
#### **2. Basics of Programming**
- **Program:** A set of instructions for a computer to execute.
- **Common First Languages:** Python, Java, C++, JavaScript.
- **Basic Concepts:**
- **Variables** (containers for data, e.g., `x = 5`)
- **Control Structures** (`if` statements, loops)
- **Functions** (reusable blocks of code)
- **Syntax & Debugging** (fixing errors in code)
**Example (Python):**
```python
if x > 10:
print("x is large")
else:
print("x is small")
```
---
#### **3. Algorithms & Efficiency**
- **Algorithm:** Step-by-step procedure to solve a problem.
- **Big-O Notation:** Measures how fast an algorithm grows (time/space complexity).
- **O(1)** – Constant time (fastest)
- **O(n)** – Linear time (scales with input size)
- **O(n²)** – Quadratic time (slow for large inputs)
**Example:**
- **Linear Search** → O(n)
- **Binary Search** → O(log n) (faster, but requires sorted data)
---
#### **4. Data Structures**
- **Arrays/Lists** – Ordered, index-based (e.g., `[1, 2, 3]`).
- **Linked Lists** – Nodes connected by pointers.
- **Stacks (LIFO) & Queues (FIFO)** – Different insertion/removal rules.
- **Hash Tables** – Fast key-value lookups (O(1) average time).
- **Trees & Graphs** – Hierarchical/networked data.
**Use Cases:**
- **Arrays** → Fast access by index.
- **Hash Tables** → Storing dictionaries (e.g., usernames & passwords).
---
#### **5. Computer Architecture Basics**
- **CPU** – Executes instructions (fetch, decode, execute).
- **Memory (RAM vs. Storage)** – RAM is fast but temporary; storage is persistent.
- **Binary & Logic Gates** – Computers use 1s and 0s (AND, OR, NOT gates).
**Moore’s Law:** Computing power doubles ~every 2 years (slowing now).
---
#### **6. Theory of Computation**
- **Turing Machine** – Abstract model of computation (what problems can be solved?).
- **P vs. NP Problem** – Can problems verified quickly also be *solved* quickly? (Unresolved!)
---
#### **7. Key Fields in CS**
- **AI/Machine Learning** (training models to predict data)
- **Cybersecurity** (protecting systems from attacks)
- **Databases** (storing & retrieving data efficiently)
- **Networking** (how data travels over the internet)
- **Software Engineering** (building large-scale applications)
---
### **Study Tips:**
✔ **Practice Coding Daily** (use platforms like LeetCode, Codecademy).
✔ **Draw Diagrams** for algorithms/data structures.
✔ **Explain Concepts Out Loud** (teach a friend!).
✔ **Debug by Breaking Problems Down** (small steps → big solution).
**Fun Fact:** The first "bug" was a literal moth stuck in a computer (1947)! 🐛💻
Would you like deeper dives into any topic? (e.g., Python syntax, sorting algorithms, etc.)