update
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
| 01 | [Download PDF]() | [Download Solution (zip)]() | |
|
| 01 | [Download PDF]() | [Download Solution (zip)]() | |
|
||||||
| 02 | [Download PDF]() | [Download Solution (zip)]() | |
|
| 02 | [Download PDF]() | [Download Solution (zip)]() | |
|
||||||
| 03 | [Download PDF]() | [Download Solution (zip)]() | |
|
| 03 | [Download PDF]() | [Download Solution (zip)]() | |
|
||||||
| 04 | [Download PDF]() | [Download Solution (zip)]() | |
|
|
||||||
|
|
||||||
> [!note] Not available yet?
|
> [!note] Not available yet?
|
||||||
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
|
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
---
|
---
|
||||||
## 🛠️ Workshop & Assignments
|
## 🛠️ Workshop & Assignments
|
||||||
|
|
||||||
- 💬 [Workshop Questions](1-Workshop.md)
|
- 💬 [Workshop Questions](01-topics/04-function-1/1-Workshop.md)
|
||||||
- 🧮 [Assignments](2-Assignment.md)
|
- 🧮 [Assignments](2-Assignment.md)
|
||||||
- ❓ [Q&A and Common Issues]()
|
- ❓ [Q&A and Common Issues]()
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
---
|
---
|
||||||
## 🛠️ Workshop & Assignments
|
## 🛠️ Workshop & Assignments
|
||||||
|
|
||||||
- 💬 [Workshop Questions]()
|
- 💬 [Workshop Questions](1-Workshop.md)
|
||||||
- 🧮 [Assignments]()
|
- 🧮 [Assignments]()
|
||||||
- ❓ [Q&A and Common Issues]()
|
- ❓ [Q&A and Common Issues]()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
> [!info] Brief description
|
||||||
|
> This page lists the **workshop questions** for this topic and provides **downloadable official solutions**.
|
||||||
|
> These questions are meant to help you apply the concepts learned in class through hands-on coding exercises.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> [!tip] How to use this page
|
||||||
|
> - Start by attempting each question on your own.
|
||||||
|
> - Use the official solutions only to review and learn better approaches.
|
||||||
|
> - If something doesn’t make sense, **ask a TA**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📦 Download All Questions and Solutions
|
||||||
|
|
||||||
|
- **All questions (zip):** [Download all questions](https://drive.usercontent.google.com/u/0/uc?id=19EIICYkB7sUmsEVB6da5eZ5MQ7WTuP88&export=download)
|
||||||
|
- **All official solutions (zip):** [Download all official solutions](https://drive.usercontent.google.com/u/0/uc?id=1j0gtsHGPOcpH8GOVAyvxFqecCze1SQH0&export=download)
|
||||||
|
|
||||||
|
---
|
||||||
|
## 🧾 Official Questions & Solutions
|
||||||
|
|
||||||
|
| Question # | Question (Download) | Official Solution (Download) | Additional Notes |
|
||||||
|
| ---------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------------- |
|
||||||
|
| 01 | [Download PDF](https://drive.usercontent.google.com/u/0/uc?id=1LZysw18yVMxIeSfI5myQ-PJEtHD5_Qgl&export=download) | [Download Solution (cpp)](https://drive.usercontent.google.com/u/0/uc?id=1piw1JTjDYyrfhyDaFOlzbwsyp0exbMws&export=download) | |
|
||||||
|
| 02 | [Download PDF](https://drive.usercontent.google.com/u/0/uc?id=1_Qvwn_c2AUgAEYWYLs2D8rwDgzklFr2-&export=download) | [Download Solution (cpp)](https://drive.usercontent.google.com/u/0/uc?id=1njLCfQOu7Wg5JOgigoLM9D8ApACNRleT&export=download) | |
|
||||||
|
| 03 | [Download PDF](https://drive.usercontent.google.com/u/0/uc?id=1bUqIBdveAywXfEIxdAMHQdvzrf2qS2H-&export=download) | [Download Solution (cpp)](https://drive.usercontent.google.com/u/0/uc?id=1Ig4BJdoivI__8_1Aj2uZm9-KRWh0zT-1&export=download) | |
|
||||||
|
|
||||||
|
> [!note] Not available yet?
|
||||||
|
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
|
||||||
|
|
||||||
|
---
|
||||||
|
## ❓ Q&A and Support
|
||||||
|
|
||||||
|
> [!question] Got stuck or confused?
|
||||||
|
> If something in a question or solution is unclear:
|
||||||
|
> - Revisit the lecture notes and workshop slides.
|
||||||
|
> - Ask your TA — that’s what we’re here for.
|
||||||
|
|
||||||
|
- [Topic Q&A](3-Q&A.md)
|
||||||
|
- [Professor Slides](4-ProfessorSlides.md)
|
||||||
|
- [TA Slides](5-TASlides.md)
|
||||||
|
---
|
||||||
|
## ⚖️ Licensing & Usage
|
||||||
|
|
||||||
|
> [!important] Usage note
|
||||||
|
> Official assignment solutions are for **educational use only**. Please do not repost them publicly or use them in ways that violate course policy.
|
||||||
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
# 🧭 Topic: Recursive Functions
|
||||||
|
|
||||||
|
> [!info] **Quick Overview :**
|
||||||
|
>Recursion is a technique where a function solves a problem by calling itself on a smaller version of that problem, using a base case to stop the process. It’s useful for naturally hierarchical tasks like divide-and-conquer algorithms, backtracking, and tree or graph traversal. While recursion can make code simpler and more intuitive, it also uses more memory and can cause stack overflows if not designed carefully. Choosing recursion vs. iteration depends on the problem’s structure, performance needs, and clarity of the solution.
|
||||||
|
|
||||||
|
## 📌 Covered in This Topic
|
||||||
|
- **1. Introduction to Recursion**
|
||||||
|
- What recursion means (functions calling themselves)
|
||||||
|
- Real-life analogy (matryoshka dolls / repeated tasks)
|
||||||
|
- Structure of every recursive function (base case + recursive case)
|
||||||
|
- **2. How Recursive Functions Are Created**
|
||||||
|
- Function call stack review (activation records, return addresses, parameters)
|
||||||
|
- Base cases: preventing infinite recursion
|
||||||
|
- Progress toward the base case (reducing the problem size)
|
||||||
|
- Tracing a simple example (factorial, Fibonacci)
|
||||||
|
- **3. Relationship Between Recursion and Iteration**
|
||||||
|
- Any recursive solution can be rewritten using loops
|
||||||
|
- Recursion as a conceptual tool vs. iteration as a control-flow tool
|
||||||
|
- Examples:
|
||||||
|
- fibonacci (recursive → iterative)
|
||||||
|
- factorial (recursive → iterative)
|
||||||
|
- When compilers internally convert tail recursion to loops
|
||||||
|
- **4. Why Use Recursion? — Problems and Use Cases**
|
||||||
|
- Problems naturally defined in terms of smaller subproblems
|
||||||
|
- Divide-and-Conquer algorithms (Merge Sort, Quick Sort)
|
||||||
|
- Backtracking problems (N-Queens, maze solving, subsets/permutations)
|
||||||
|
- Tree/graph traversal (DFS)
|
||||||
|
- Mathematical sequences (Fibonacci, exponentiation)
|
||||||
|
- **5. How to Choose Between Recursion and Iteration**
|
||||||
|
- Use recursion when the problem is hierarchical, branching, or naturally recursive
|
||||||
|
- Use iteration when performance and memory are critical
|
||||||
|
- Avoid recursion when depth may be very large (risk of stack overflow)
|
||||||
|
- Consider readability vs. efficiency trade-offs
|
||||||
|
- **6. Problems With Recursion**
|
||||||
|
- High memory usage: stack frames
|
||||||
|
- Stack overflow (deep recursion)
|
||||||
|
- Re-computation of subproblems (e.g., naive Fibonacci)
|
||||||
|
- Harder to debug for beginners
|
||||||
|
- Function call overhead
|
||||||
|
- **7. Solutions and Optimizations**
|
||||||
|
- **Tail Recursion**
|
||||||
|
- What tail recursion is
|
||||||
|
- How compilers can optimize it
|
||||||
|
- Example of turning a normal recursion into tail recursion
|
||||||
|
- **Memoization**
|
||||||
|
- Caching results of recursive calls
|
||||||
|
- When to use it (DP top-down)
|
||||||
|
- Example: optimized Fibonacci
|
||||||
|
- **8. Worked Examples**
|
||||||
|
- **N-Queens** (backtracking)
|
||||||
|
- **Merge Sort** (divide-and-conquer)
|
||||||
|
- **Tail-recursive factorial**
|
||||||
|
- **Memoized Fibonacci**
|
||||||
|
|
||||||
|
---
|
||||||
|
## 📑 Slides & Materials
|
||||||
|
- 🧑🏫 [TA Workshop Slides (PDF)](5-TASlides.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
## 🛠️ Workshop & Assignments
|
||||||
|
|
||||||
|
- 💬 [Workshop Questions](01-topics/05-arrays/1-Workshop.md)
|
||||||
|
- 🧮 [Assignments](2-Assignment.md)
|
||||||
|
- ❓ [Q&A and Common Issues]()
|
||||||
|
|
||||||
|
---
|
||||||
|
## 🌐 Additional Resources
|
||||||
|
- C++ Reference (cplusplus.com)
|
||||||
|
|
||||||
|
---
|
||||||
|
## ⏩ Navigation
|
||||||
|
|
||||||
|
- ⬅️ [Previous : Arrays](../05-arrays/0-Overview.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> [!tip] **Tip :**
|
||||||
|
>
|
||||||
|
> If something doesn’t make sense — **don’t stay stuck alone**. Ask the TA to clarify it right away. Often, a quick question can save you a lot of time and frustration. Remember: if you’re confused, chances are others are too.
|
||||||
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
> [!info] Brief description
|
||||||
|
> This page lists the **workshop questions** for this topic and provides **downloadable official solutions**.
|
||||||
|
> These questions are meant to help you apply the concepts learned in class through hands-on coding exercises.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> [!tip] How to use this page
|
||||||
|
> - Start by attempting each question on your own.
|
||||||
|
> - Use the official solutions only to review and learn better approaches.
|
||||||
|
> - If something doesn’t make sense, **ask a TA**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📦 Download All Questions and Solutions
|
||||||
|
|
||||||
|
- **All questions (zip):** [Download all questions](https://drive.google.com/file/d/1zF0PlsAb93appBlVKzaU1vg0OfWW2bbH/view?usp=drive_link)
|
||||||
|
- **All official solutions (zip):** [Download all official solutions](https://drive.usercontent.google.com/u/0/uc?id=19loXWcw0-SaDWalWclog2UB0G9-J6xxM&export=download)
|
||||||
|
|
||||||
|
---
|
||||||
|
## 🧾 Official Questions & Solutions
|
||||||
|
|
||||||
|
| Question # | Question (Download) | Official Solution (Download) | Additional Notes |
|
||||||
|
| ---------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------------- |
|
||||||
|
| 01 | [Download PDF](https://drive.usercontent.google.com/u/0/uc?id=1DirYsWV3mMCjQIdzrg06gcbNm7RbFGZL&export=download) | [Download Solution (cpp)](https://drive.usercontent.google.com/u/0/uc?id=16LpfS3TecRIAGb3JyX220BVeJC2Glbs9&export=download) | |
|
||||||
|
| 02 | [Download PDF](https://drive.usercontent.google.com/u/0/uc?id=1WyIvN5Q7bCQbeyWqyAQZ5FZYUmoIyncn&export=download) | [Download Solution (cpp)](https://drive.usercontent.google.com/u/0/uc?id=15ID29lsJkttKzHwyJGM5CP4_HjU78c-m&export=download) | |
|
||||||
|
| 03 | [Download PDF](https://drive.google.com/file/d/1JQBErHxHlpWXNsSbxMMv9K-RfGCzrPYE/view?usp=drive_link) | [Download Solution (cpp)](https://drive.usercontent.google.com/u/0/uc?id=1TmQRCipD8p_0c7Ckwtw81dUYry9utURw&export=download) | |
|
||||||
|
|
||||||
|
> [!note] Not available yet?
|
||||||
|
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
|
||||||
|
|
||||||
|
---
|
||||||
|
## ❓ Q&A and Support
|
||||||
|
|
||||||
|
> [!question] Got stuck or confused?
|
||||||
|
> If something in a question or solution is unclear:
|
||||||
|
> - Revisit the lecture notes and workshop slides.
|
||||||
|
> - Ask your TA — that’s what we’re here for.
|
||||||
|
|
||||||
|
|
||||||
|
- [TA Slides](5-TASlides.md)
|
||||||
|
---
|
||||||
|
## ⚖️ Licensing & Usage
|
||||||
|
|
||||||
|
> [!important] Usage note
|
||||||
|
> Official assignment solutions are for **educational use only**. Please do not repost them publicly or use them in ways that violate course policy.
|
||||||
|
|
||||||
Reference in New Issue
Block a user