DevJourney · code I wrote while learning

README.md

2.5 KB

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.cpp to connect theory with code.

Problems (click for details)

  1. Huffman Coding — 01_Huffman_Coding/README.md — Code: main.cpp
  2. Assembly Line Scheduling — 02_Assembly_Line_Scheduling/README.md — Code: main.cpp
  3. Matrix Chain Multiplication — 03_Matrix_Chain_Multiplication/README.md — Code: main.cpp
  4. Longest Common Subsequence — 04_Longest_Common_Subsequence/README.md — Code: main.cpp
  5. 0-1 Knapsack — 05_0-1_Knapsack/README.md — Code: main.cpp
  6. Maximum Subarray — 06_Maximum_Subarray/README.md — Code: main.cpp
  7. Karatsuba Multiplication — 07_Karatsuba/README.md — Code: main.cpp
  8. N‑Queens — 08_N_Queens/README.md — Code: main.cpp
  9. Job Selection (BnB) — 09_Job_Selection_BnB/README.md — Code: main.cpp
  10. 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.