Algorithms Lab — C++ Implementations (LCP)
This folder contains study-ready explanations and clear C++ implementations for ten classic algorithms used in the LCP / Algorithms lab. Each subfolder includes:
- a concise problem statement
- the main idea and a short pseudocode sketch
- complexity analysis and practical notes
- a worked example you can trace by hand
- the reference implementation in
main.cpp
How to compile and run
- Build:
g++ -std=c++17 -O2 main.cpp -o main.exe - Run (Windows PowerShell):
.\\main.exe - Run (Linux/macOS):
./main.exe
Study tips
- Read the problem statement, then the algorithm idea, then step through the worked example by hand.
- Compare the pseudocode to the implementation in
main.cppto connect theory with code.
Problems (click for details)
- Huffman Coding — 01_Huffman_Coding/README.md — Code: main.cpp
- Assembly Line Scheduling — 02_Assembly_Line_Scheduling/README.md — Code: main.cpp
- Matrix Chain Multiplication — 03_Matrix_Chain_Multiplication/README.md — Code: main.cpp
- Longest Common Subsequence — 04_Longest_Common_Subsequence/README.md — Code: main.cpp
- 0-1 Knapsack — 05_0-1_Knapsack/README.md — Code: main.cpp
- Maximum Subarray — 06_Maximum_Subarray/README.md — Code: main.cpp
- Karatsuba Multiplication — 07_Karatsuba/README.md — Code: main.cpp
- N‑Queens — 08_N_Queens/README.md — Code: main.cpp
- Job Selection (BnB) — 09_Job_Selection_BnB/README.md — Code: main.cpp
- Fractional Knapsack — 10_Fractional_Knapsack/README.md — Code: main.cpp
References
- CLRS — Introduction to Algorithms
- Huffman (1952) and standard algorithms texts
If you'd like, I can add a tests/ directory with sample inputs and expected outputs for each problem, or run each main.cpp and paste the sample outputs into the README files. Tell me which you'd prefer.