Student Portal

Assignments & Coursework

Submit assignments, view teacher remarks, and receive instant AI rubric feedback

CS301

Problem Set 3: Dynamic Programming Optimization

Due: 8/20/2026Graded: 95 / 100

Implement O(N log N) solution for Longest Increasing Subsequence and 2D Knapsack with memory constraints. Include mathematical proofs of optimal substructure.

Grading Criteria:Algorithm Correctness & Complexity (40%)Mathematical Proof of Subproblems (30%)Clean Code & Test Coverage (30%)
Your Submission8/15/2026, 2:30:00 PM
### Dynamic Programming Solution: Longest Increasing Subsequence

We utilize patience sorting combined with binary search to achieve O(N log N) time complexity.

```python
import bisect

def length_of_lis(nums):
    tails = []
    for x in nums:
        idx = bisect.bisect_left(tails, x)
        if idx == len(tails):
            tails.append(x)
        else:
            tails[idx] = x
    return len(tails)
```

**Proof of Optimality:** Each tail[i] maintains the minimum ending value of an increasing subsequence of length i + 1. Since tails is strictly increasing, binary search is valid.
AI Rubric Diagnostic & Feedback (gemini-1.5-flash)Score: 95 / 100

Exemplary solution with optimal O(N log N) complexity and rigorous mathematical proof.

Key Strengths:

• Clean vector-friendly implementation

• Flawless inductive proof of the tails array

Areas for Growth:

• Could briefly discuss memory allocation overhead in large arrays

AI402

Mini-Project: Multi-Head Attention from Scratch

Due: 8/24/2026Pending Submission

Build a vectorized Multi-Head Self-Attention layer in PyTorch without using torch.nn.MultiheadAttention. Benchmark against naive loops and verify causal masking.

Grading Criteria:Vectorization & Tensor Shapes (50%)Masking Logic (30%)Benchmarking Report (20%)
DashboardCoursesTasksExamsAI Advisor