<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Algorithms on Thanh HV's Blog</title><link>https://thanhhv.github.io/tags/algorithms/</link><description>Recent content in Algorithms on Thanh HV's Blog</description><generator>Hugo -- 0.146.7</generator><language>en-us</language><lastBuildDate>Mon, 20 Jul 2026 11:30:00 +0700</lastBuildDate><atom:link href="https://thanhhv.github.io/tags/algorithms/index.xml" rel="self" type="application/rss+xml"/><item><title>Chương 27 — Production Case Studies: Toán học trong các hệ thống tỷ đô</title><link>https://thanhhv.github.io/series/math-for-engineers/level-5-production/27-production-case-studies/</link><pubDate>Mon, 20 Jul 2026 11:30:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-5-production/27-production-case-studies/</guid><description>&lt;blockquote>
&lt;p>Level 5 – Production
Yêu cầu trước: toàn bộ tài liệu — chương này là nơi mọi mảnh ghép gặp nhau&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="mở-đầu-đọc-kiến-trúc-như-đọc-một-chứng-minh">Mở đầu: đọc kiến trúc như đọc một chứng minh&lt;/h2>
&lt;p>Sau 26 chương, bạn đã có trong tay một hộp công cụ: đếm và xác suất, graph và cây, DP và greedy, đại số tuyến tính và thống kê, entropy và số học modular. Chương cuối này làm một việc duy nhất: &lt;strong>mở nắp capo của mười hệ thống tỷ đô và chỉ tay vào đúng chỗ toán học đang nằm&lt;/strong>.&lt;/p></description></item><item><title>Chương 26 — Cryptography Mathematics: Bảo mật xây trên nền toán học</title><link>https://thanhhv.github.io/series/math-for-engineers/level-5-production/26-cryptography/</link><pubDate>Mon, 20 Jul 2026 11:20:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-5-production/26-cryptography/</guid><description>&lt;blockquote>
&lt;p>Level 5 – Production
Yêu cầu trước: Chương 11 (Probability), Chương 12 (Hashing), Chương 19 (Number Theory)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Hãy tưởng tượng tình huống này: bạn và một người lạ chưa từng gặp nhau, chưa từng trao đổi bất kỳ bí mật nào, đứng ở hai đầu một căn phòng đông người. Mọi câu các bạn nói đều bị cả phòng nghe thấy. Nhiệm vụ: hai người phải thỏa thuận được một con số bí mật mà &lt;strong>không ai khác trong phòng biết&lt;/strong> — dù họ nghe được từng từ.&lt;/p></description></item><item><title>Chương 25 — Distributed Systems Mathematics: Toán của sự không chắc chắn</title><link>https://thanhhv.github.io/series/math-for-engineers/level-5-production/25-distributed-systems-math/</link><pubDate>Mon, 20 Jul 2026 11:10:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-5-production/25-distributed-systems-math/</guid><description>&lt;blockquote>
&lt;p>Level 5 – Production
Yêu cầu trước: Chương 02 (Set Theory, Functions &amp;amp; Relations), Chương 05 (Counting &amp;amp; Combinatorics), Chương 11 (Probability), Chương 12 (Hashing), Chương 19 (Number Theory)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Lúc 14:03:07.421 theo đồng hồ của server tại Singapore, một user bấm nút &amp;ldquo;Mua&amp;rdquo;. Lúc 14:03:07.418 — &lt;em>sớm hơn 3 millisecond&lt;/em> — theo đồng hồ của server tại Virginia, chính user đó bấm &amp;ldquo;Hủy đơn&amp;rdquo;. Câu hỏi tưởng như tầm thường: &lt;strong>hành động nào xảy ra trước?&lt;/strong>&lt;/p></description></item><item><title>Chương 24 — Advanced Data Structures: Công cụ chuyên dụng cho truy vấn chuyên dụng</title><link>https://thanhhv.github.io/series/math-for-engineers/level-5-production/24-advanced-data-structures/</link><pubDate>Mon, 20 Jul 2026 11:00:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-5-production/24-advanced-data-structures/</guid><description>&lt;blockquote>
&lt;p>Level 5 – Production
Yêu cầu trước: Chương 07 (Trees), Chương 09 (Boolean Algebra), Chương 12 (Hashing)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một team xây tính năng autocomplete cho ô tìm kiếm sản phẩm. Dữ liệu: 2 triệu tên sản phẩm. Giải pháp đầu tiên rất tự nhiên: đổ tất cả vào hash map&amp;hellip; và bế tắc ngay lập tức. Hash map trả lời &amp;ldquo;chuỗi này &lt;em>có tồn tại&lt;/em> không?&amp;rdquo; trong O(1) — nhưng autocomplete hỏi câu hoàn toàn khác: &amp;ldquo;chuỗi nào &lt;em>bắt đầu bằng&lt;/em> &lt;code>iph&lt;/code>?&amp;rdquo;. Hash của &lt;code>iph&lt;/code> không nói gì về hash của &lt;code>iphone 15 pro&lt;/code> — hàm hash tốt &lt;strong>cố tình phá hủy&lt;/strong> mọi cấu trúc của key (chương 12). Truy vấn prefix trên hash map là full scan.&lt;/p></description></item><item><title>Chương 23 — Probabilistic Data Structures: Đổi độ chính xác lấy bộ nhớ</title><link>https://thanhhv.github.io/series/math-for-engineers/level-5-production/23-probabilistic-data-structures/</link><pubDate>Mon, 20 Jul 2026 10:50:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-5-production/23-probabilistic-data-structures/</guid><description>&lt;blockquote>
&lt;p>Level 5 – Production
Yêu cầu trước: Chương 10 (Complexity), Chương 11 (Probability), Chương 12 (Hashing)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Bạn đang xây dựng một web crawler quy mô lớn. Trước khi tải một URL, crawler phải trả lời câu hỏi tưởng như tầm thường: &lt;strong>&amp;ldquo;URL này đã crawl chưa?&amp;rdquo;&lt;/strong>&lt;/p>
&lt;p>Cách hiển nhiên: một hash set chứa mọi URL đã thấy. Làm phép tính với 10 tỷ URL, mỗi URL trung bình 80 byte, cộng overhead của hash table (con trỏ, bucket, hệ số load factor):&lt;/p></description></item><item><title>Chương 22 — Computational Geometry: Toán của không gian vật lý</title><link>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/22-computational-geometry/</link><pubDate>Mon, 20 Jul 2026 10:40:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/22-computational-geometry/</guid><description>&lt;blockquote>
&lt;p>Level 4 – Advanced Mathematics
Yêu cầu trước: Chương 07 (Trees), Chương 13 (Divide &amp;amp; Conquer), Chương 17 (Linear Algebra)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Bạn nhận một ticket tưởng như đơn giản: &amp;ldquo;API trả về 10 quán cà phê gần người dùng nhất, p99 dưới 50ms.&amp;rdquo; Database có 5 triệu địa điểm, mỗi địa điểm là một cặp (latitude, longitude).&lt;/p>
&lt;p>Bản nháp đầu tiên ai cũng viết được: tính khoảng cách từ người dùng đến &lt;em>từng&lt;/em> địa điểm, sort, lấy 10. Đó là 5 triệu phép tính khoảng cách (mỗi phép có sin/cos nếu tính đúng trên mặt cầu) cộng một lần sort — hàng trăm millisecond cho &lt;em>một&lt;/em> request. Với 1.000 request/giây, bạn cần một cụm máy chỉ để trả lời câu hỏi &amp;ldquo;gần đây có gì&amp;rdquo;.&lt;/p></description></item><item><title>Chương 21 — Optimization: Tìm cực trị trong không gian ràng buộc</title><link>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/21-optimization/</link><pubDate>Mon, 20 Jul 2026 10:30:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/21-optimization/</guid><description>&lt;blockquote>
&lt;p>Level 4 – Advanced Mathematics
Yêu cầu trước: Chương 10 (Complexity), Chương 14 (Dynamic Programming), Chương 15 (Greedy)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Cluster Kubernetes của bạn có 40 node, mỗi node 16 vCPU và 64GB RAM. Có 300 pod cần chạy, mỗi pod khai báo request CPU/memory khác nhau, một số pod phải cùng node với nhau (affinity), một số tuyệt đối không được cùng node (anti-affinity), vài pod cần GPU. Hóa đơn cloud tính theo số node bật. Câu hỏi của sếp rất gọn: &lt;strong>&amp;ldquo;Xếp thế nào để bật ít node nhất?&amp;rdquo;&lt;/strong>&lt;/p></description></item><item><title>Chương 20 — Information Theory: Đo lường thông tin và giới hạn của nén</title><link>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/20-information-theory/</link><pubDate>Mon, 20 Jul 2026 10:20:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/20-information-theory/</guid><description>&lt;blockquote>
&lt;p>Level 4 – Advanced Mathematics
Yêu cầu trước: Chương 07 (Trees), Chương 11 (Probability), Chương 15 (Greedy)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Hãy làm một thí nghiệm mất 30 giây. Lấy một file log text 100MB, chạy &lt;code>gzip&lt;/code>: file co lại còn ~25MB — nén được 75%. Lấy một file JPEG 100MB, chạy &lt;code>gzip&lt;/code>: file thu được ~99.9MB, thậm chí đôi khi &lt;em>lớn hơn&lt;/em> file gốc. Cùng một thuật toán, cùng 100MB đầu vào, một bên nén được 75%, một bên 0%.&lt;/p></description></item><item><title>Chương 19 — Number Theory: Số học của máy tính và mật mã</title><link>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/19-number-theory/</link><pubDate>Mon, 20 Jul 2026 10:10:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/19-number-theory/</guid><description>&lt;blockquote>
&lt;p>Level 4 – Advanced Mathematics
Yêu cầu trước: Chương 03 (Proof Techniques), Chương 11 (Probability), Chương 12 (Hashing)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Ngày 4 tháng 6 năm 1996, tên lửa Ariane 5 của Cơ quan Vũ trụ châu Âu phát nổ 37 giây sau khi rời bệ phóng, mang theo thiết bị trị giá khoảng 370 triệu USD. Nguyên nhân gốc, sau nhiều tháng điều tra: một đoạn code tái sử dụng từ Ariane 4 chuyển giá trị vận tốc ngang từ số thực 64-bit sang số nguyên 16-bit. Ariane 5 bay nhanh hơn Ariane 4; giá trị vượt quá 32767; phép chuyển đổi tràn số; hệ thống dẫn đường tự tắt. Không phải lỗi thuật toán, không phải lỗi logic — chỉ là một con số vượt ra ngoài chiếc hộp chứa nó.&lt;/p></description></item><item><title>Chương 18 — Statistics: Đọc hiểu hệ thống qua dữ liệu</title><link>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/18-statistics/</link><pubDate>Mon, 20 Jul 2026 10:00:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/18-statistics/</guid><description>&lt;blockquote>
&lt;p>Level 4 – Advanced Mathematics
Yêu cầu trước: Chương 11 (Probability), Chương 16 (Sorting, Searching &amp;amp; Heap)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một buổi sáng thứ Hai, team backend nhận ticket từ customer support: &amp;ldquo;Nhiều khách hàng phàn nàn app chậm, có người chờ 3–4 giây mới load xong trang chủ.&amp;rdquo; Kỹ sư trực mở dashboard, nhìn vào biểu đồ latency của API gateway: &lt;strong>average response time = 52ms&lt;/strong>, ổn định suốt tuần. Anh trả lời ticket: &amp;ldquo;Hệ thống bình thường, có thể do mạng phía khách hàng.&amp;rdquo;&lt;/p></description></item><item><title>Chương 17 — Linear Algebra: Ngôn ngữ của AI và không gian nhiều chiều</title><link>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/17-linear-algebra/</link><pubDate>Mon, 20 Jul 2026 09:50:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-4-advanced-mathematics/17-linear-algebra/</guid><description>&lt;blockquote>
&lt;p>Level 4 – Advanced Mathematics
Yêu cầu trước: Chương 02 (Set Theory, Functions &amp;amp; Relations), Chương 10 (Complexity Analysis), Chương 11 (Probability)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Người dùng gõ vào ô tìm kiếm của trang thương mại điện tử: &amp;ldquo;đồ giữ ấm cho bé mùa đông&amp;rdquo;. Kho hàng có sản phẩm tên &amp;ldquo;Áo khoác lông cừu trẻ em&amp;rdquo; — không chung một từ nào với query. Full-text search truyền thống (kể cả Elasticsearch với inverted index từ chương 10) trả về &lt;strong>0 kết quả&lt;/strong>: nó tìm &lt;em>từ&lt;/em>, không tìm &lt;em>nghĩa&lt;/em>. Team thử vá bằng từ điển đồng nghĩa — và nhanh chóng chết chìm: &amp;ldquo;giữ ấm&amp;rdquo; ~ &amp;ldquo;khoác&amp;rdquo; ~ &amp;ldquo;len&amp;rdquo; ~ &amp;ldquo;nỉ&amp;rdquo; ~ &amp;ldquo;lông cừu&amp;rdquo;&amp;hellip;, tổ hợp nổ theo cấp số nhân, tiếng Việt lại còn &amp;ldquo;bé&amp;rdquo; ~ &amp;ldquo;trẻ em&amp;rdquo; ~ &amp;ldquo;em bé&amp;rdquo; ~ &amp;ldquo;kids&amp;rdquo;. Không ai bảo trì nổi.&lt;/p></description></item><item><title>Chương 16 — Sorting, Searching &amp; Heap: Trật tự và cái giá của nó</title><link>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/16-sorting-searching-heap/</link><pubDate>Mon, 20 Jul 2026 09:40:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/16-sorting-searching-heap/</guid><description>&lt;blockquote>
&lt;p>Level 3 – Algorithm Mathematics
Yêu cầu trước: Chương 05 (Counting &amp;amp; Combinatorics), Chương 10 (Complexity Analysis), Chương 11 (Probability), Chương 13 (Divide and Conquer)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một team backend nhận yêu cầu tưởng như tầm thường: trang admin cần hiển thị &amp;ldquo;100 đơn hàng giá trị cao nhất trong ngày&amp;rdquo; từ một bảng 50 triệu dòng. Phiên bản đầu tiên: &lt;code>ORDER BY amount DESC LIMIT 100&lt;/code>. Query mất 40 giây và đẩy database vào swap — PostgreSQL đang sort toàn bộ 50 triệu dòng chỉ để vứt đi 49.999.900 dòng đầu ra.&lt;/p></description></item><item><title>Chương 15 — Greedy Algorithms: Khi nào tham lam là đúng</title><link>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/15-greedy/</link><pubDate>Mon, 20 Jul 2026 09:30:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/15-greedy/</guid><description>&lt;blockquote>
&lt;p>Level 3 – Algorithm Mathematics
Yêu cầu trước: Chương 10 (Complexity Analysis), Chương 14 (Dynamic Programming)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một team platform triển khai autoscaler tự viết: mỗi khi tải tăng, chọn ngay hành động rẻ nhất &lt;em>tại thời điểm đó&lt;/em> — thêm một pod vào node đang trống nhất. Từng quyết định riêng lẻ đều hợp lý. Ba tháng sau, cluster rơi vào trạng thái kỳ dị: pod rải vụn khắp nơi, không node nào trống đủ để nhận workload lớn, và chi phí cao hơn 40% so với phương án xếp lại từ đầu. Không quyết định nào sai — nhưng &lt;strong>chuỗi quyết định&lt;/strong> thì sai.&lt;/p></description></item><item><title>Chương 14 — Dynamic Programming: Đừng tính lại thứ đã tính</title><link>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/14-dynamic-programming/</link><pubDate>Mon, 20 Jul 2026 09:20:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/14-dynamic-programming/</guid><description>&lt;blockquote>
&lt;p>Level 3 – Algorithm Mathematics
Yêu cầu trước: Chương 06 (Recurrence), Chương 13 (Divide and Conquer)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Mỗi lần bạn gõ &lt;code>git diff&lt;/code>, Git phải trả lời một câu hỏi nghe đơn giản: &lt;em>chuỗi thao tác thêm/xóa ngắn nhất để biến file cũ thành file mới là gì?&lt;/em> Với hai file 1.000 dòng, số cách &amp;ldquo;căn chỉnh&amp;rdquo; hai file với nhau nhiều hơn số nguyên tử trong vũ trụ quan sát được. Vậy mà Git trả lời trong vài mili giây — không phải bằng phép màu, mà bằng một quan sát toán học: hàng tỷ tỷ cách căn chỉnh đó được lắp ráp từ một số lượng &lt;strong>rất nhỏ&lt;/strong> các bài toán con phân biệt, mỗi bài chỉ cần giải đúng một lần.&lt;/p></description></item><item><title>Chương 13 — Divide and Conquer: Sức mạnh của chia đôi</title><link>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/13-divide-and-conquer/</link><pubDate>Mon, 20 Jul 2026 09:10:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/13-divide-and-conquer/</guid><description>&lt;blockquote>
&lt;p>Level 3 – Algorithm Mathematics
Yêu cầu trước: Chương 06 (Recurrence), Chương 10 (Complexity Analysis)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Năm 2004, Jeffrey Dean và Sanjay Ghemawat công bố paper MapReduce, mô tả cách Google đánh index toàn bộ web — hàng chục tỷ trang — bằng những cụm máy rẻ tiền, hỏng liên tục. Cộng đồng kỹ thuật lúc đó xem đây là một cuộc cách mạng về hệ thống phân tán. Nhưng nếu đọc kỹ paper, ý tưởng cốt lõi không mới: &lt;strong>chia bài toán khổng lồ thành các mảnh độc lập, giải từng mảnh, rồi ghép kết quả lại&lt;/strong>. Đó chính là Divide and Conquer — kỹ thuật mà John von Neumann đã dùng để thiết kế merge sort từ năm 1945, gần 60 năm trước.&lt;/p></description></item><item><title>Chương 12 — Hashing: Nén vô hạn vào hữu hạn</title><link>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/12-hashing/</link><pubDate>Mon, 20 Jul 2026 09:00:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/12-hashing/</guid><description>&lt;blockquote>
&lt;p>Level 3 – Algorithm Mathematics
Yêu cầu trước: Chương 05 (Counting &amp;amp; Combinatorics — Pigeonhole), Chương 11 (Probability)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Tháng 12 năm 2011, tại hội nghị bảo mật 28C3 ở Berlin, hai nhà nghiên cứu trình diễn một cuộc tấn công khiến cả ngành web giật mình: với &lt;strong>một request POST duy nhất&lt;/strong> cỡ vài trăm KB, họ ghim CPU của một server PHP ở mức 100% trong nhiều phút. Không tràn bộ đệm, không SQL injection, không lỗi nào trong code ứng dụng. Vũ khí là toán học: họ tính trước hàng chục nghìn chuỗi &lt;strong>có cùng giá trị hash&lt;/strong>, gửi chúng làm tên tham số form. Hash table đựng tham số — cấu trúc &amp;ldquo;O(1)&amp;rdquo; mà mọi framework tin tưởng — suy biến thành một danh sách liên kết dài, mỗi thao tác chèn thành O(n), tổng xử lý một request thành O(n²). PHP, Java, Python, Ruby, ASP.NET đều dính. Các bản vá khẩn cấp được tung ra trong vài tuần, và ngôn ngữ sinh sau như Go được thiết kế với hash seed ngẫu nhiên ngay từ đầu vì bài học này.&lt;/p></description></item><item><title>Chương 11 — Probability: Đánh cược có tính toán</title><link>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/11-probability/</link><pubDate>Mon, 20 Jul 2026 08:50:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/11-probability/</guid><description>&lt;blockquote>
&lt;p>Level 3 – Algorithm Mathematics
Yêu cầu trước: Chương 05 (Counting &amp;amp; Combinatorics), Chương 10 (Complexity Analysis)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Ngày 24 tháng 12 năm 2012, Netflix sập đúng đêm Giáng sinh. Nguyên nhân gốc nằm ở AWS Elastic Load Balancer, nhưng điều biến một sự cố cục bộ thành sự cố toàn vùng là thứ khác: khi dịch vụ chập chờn, &lt;strong>hàng triệu client retry cùng một lúc, theo cùng một lịch&lt;/strong>. Mỗi client đều làm điều &amp;ldquo;đúng đắn&amp;rdquo; — thử lại sau 1 giây, rồi 2 giây, rồi 4 giây. Nhưng vì tất cả thất bại cùng thời điểm, tất cả cũng quay lại gõ cửa cùng thời điểm, như một đội quân diễu hành làm sập cây cầu bằng nhịp bước đồng bộ. Backend vừa ngóc đầu dậy lại bị đạp xuống. Giải pháp mà mọi cloud provider ngày nay khuyến cáo nghe như một trò đùa: &lt;strong>thêm ngẫu nhiên vào thời gian chờ&lt;/strong>. Sự hỗn loạn có chủ đích cứu hệ thống mà kỷ luật tuyệt đối đã giết chết.&lt;/p></description></item><item><title>Chương 10 — Complexity Analysis: Ngôn ngữ đo lường thuật toán</title><link>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/10-complexity-analysis/</link><pubDate>Mon, 20 Jul 2026 08:40:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-3-algorithm-mathematics/10-complexity-analysis/</guid><description>&lt;blockquote>
&lt;p>Level 3 – Algorithm Mathematics
Yêu cầu trước: Chương 03 (Proof Techniques), Chương 06 (Recurrence)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Năm 2010, một kỹ sư tại một công ty thương mại điện tử viết đoạn code kiểm tra sản phẩm trùng lặp: với mỗi sản phẩm, duyệt qua toàn bộ danh sách để tìm bản sao. Code chạy hoàn hảo trên môi trường dev với 1.000 sản phẩm — mất 2ms. Sáu tháng sau, catalog đạt 2 triệu sản phẩm, và cron job đó chiếm trọn một CPU core trong 4 giờ mỗi đêm.&lt;/p></description></item><item><title>Chương 09 — Boolean Algebra: Đại số của bật và tắt</title><link>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/09-boolean-algebra/</link><pubDate>Mon, 20 Jul 2026 08:30:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/09-boolean-algebra/</guid><description>&lt;blockquote>
&lt;p>Level 2 – Discrete Mathematics
Yêu cầu trước: Chương 01 (Logic), Chương 02 (Set Theory)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một team analytics cần trả lời câu hỏi tưởng như tầm thường: &amp;ldquo;hôm qua có bao nhiêu user active, và bao nhiêu user active cả 7 ngày liên tiếp?&amp;rdquo; Hệ thống có 100 triệu user. Giải pháp đầu tiên: bảng &lt;code>daily_active(user_id, date)&lt;/code>, mỗi ngày ghi vài chục triệu dòng, câu hỏi &amp;ldquo;active 7 ngày liên tiếp&amp;rdquo; trở thành JOIN 7 bảng con — chạy hàng phút, tốn hàng chục GB.&lt;/p></description></item><item><title>Chương 08 — Graph Theory: Mô hình của mọi mối quan hệ</title><link>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/08-graphs/</link><pubDate>Mon, 20 Jul 2026 08:20:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/08-graphs/</guid><description>&lt;blockquote>
&lt;p>Level 2 – Discrete Mathematics
Yêu cầu trước: Chương 02 (Set Theory, Functions &amp;amp; Relations), Chương 03 (Proof Techniques), Chương 07 (Trees)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một buổi sáng thứ Hai, hệ thống thanh toán của một công ty fintech đứng hình. Không crash, không error log, không CPU spike — chỉ đơn giản là mọi transaction treo vô hạn. Nguyên nhân: transaction A giữ lock trên bảng &lt;code>accounts&lt;/code> và chờ lock trên &lt;code>ledger&lt;/code>; transaction B giữ lock trên &lt;code>ledger&lt;/code> và chờ lock trên &lt;code>orders&lt;/code>; transaction C giữ &lt;code>orders&lt;/code> và chờ &lt;code>accounts&lt;/code>. Ba transaction chờ nhau theo một vòng tròn khép kín — &lt;strong>deadlock&lt;/strong>.&lt;/p></description></item><item><title>Chương 07 — Trees: Vì sao database index có dạng cây</title><link>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/07-trees/</link><pubDate>Mon, 20 Jul 2026 08:10:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/07-trees/</guid><description>&lt;blockquote>
&lt;p>Level 2 – Discrete Mathematics
Yêu cầu trước: Chương 03 (Proof Techniques), Chương 06 (Recurrence Relations)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một bảng PostgreSQL chứa 1 tỷ dòng. Bạn chạy &lt;code>SELECT * FROM orders WHERE id = 4815162342&lt;/code> và nhận kết quả sau &lt;strong>dưới 1 millisecond&lt;/strong>. Dừng lại và thấy điều đó vô lý đến mức nào: 1 tỷ dòng, mỗi dòng vài trăm byte — bảng nặng vài trăm GB. Đọc tuần tự từ SSD với tốc độ 2 GB/s mất vài phút. Ngay cả khi toàn bộ dữ liệu nằm sẵn trong RAM, scan tuyến tính 1 tỷ dòng cũng tốn cả giây. Vậy mà database trả lời trong thời gian đủ để ánh sáng đi được 300 km.&lt;/p></description></item><item><title>Chương 06 — Recurrence Relations: Ngôn ngữ của đệ quy</title><link>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/06-recurrence/</link><pubDate>Mon, 20 Jul 2026 08:00:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/06-recurrence/</guid><description>&lt;blockquote>
&lt;p>Level 2 – Discrete Mathematics
Yêu cầu trước: Chương 03 (Proof Techniques), Chương 05 (Counting &amp;amp; Combinatorics)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một kỹ sư viết hàm tính giá cho sản phẩm bảo hiểm: giá năm thứ n phụ thuộc vào giá hai năm trước đó theo công thức nghiệp vụ. Cách tự nhiên nhất là dịch thẳng công thức thành đệ quy. Code đúng tuyệt đối, unit test xanh với n = 10, n = 20. Rồi một khách hàng nhập hợp đồng 50 năm — và request treo. Không lỗi, không panic, không log. CPU 100%. Với n = 50, hàm đó thực hiện khoảng &lt;strong>hai mươi tỷ lời gọi&lt;/strong> cho một phép tính mà bản chất chỉ cần 50 phép cộng.&lt;/p></description></item><item><title>Chương 05 — Counting &amp; Combinatorics: Đếm mà không cần liệt kê</title><link>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/05-counting-combinatorics/</link><pubDate>Mon, 20 Jul 2026 07:50:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-2-discrete-mathematics/05-counting-combinatorics/</guid><description>&lt;blockquote>
&lt;p>Level 2 – Discrete Mathematics
Yêu cầu trước: Chương 01 (Logic), Chương 02 (Set Theory, Functions &amp;amp; Relations)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một team platform chuẩn bị release tính năng mới đứng sau 12 feature flags. QA lead hỏi câu tưởng chừng đơn giản: &amp;ldquo;Chúng ta có cần test mọi tổ hợp bật/tắt không?&amp;rdquo; Một kỹ sư mở laptop định viết script liệt kê tất cả các tổ hợp ra file để đếm. Script chạy được vài giây thì anh dừng lại và làm phép tính nhẩm: mỗi flag có 2 trạng thái, 12 flags → 2¹² = 4.096 tổ hợp. Nếu thêm 3 môi trường deploy và 4 tier khách hàng, con số thành 4.096 × 3 × 4 = &lt;strong>49.152 kịch bản test&lt;/strong>. Với 5 phút mỗi kịch bản, đó là 6 tháng làm việc liên tục.&lt;/p></description></item><item><title>Chương 04 — Mathematical Modeling: Từ bài toán thực tế đến mô hình toán</title><link>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/04-mathematical-modeling/</link><pubDate>Mon, 20 Jul 2026 07:40:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/04-mathematical-modeling/</guid><description>&lt;blockquote>
&lt;p>Level 1 – Mathematical Thinking
Yêu cầu trước: Chương 01 (Logic), Chương 02 (Set Theory, Functions &amp;amp; Relations), Chương 03 (Proof Techniques)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một buổi system design interview. Ứng viên được yêu cầu: &amp;ldquo;Thiết kế tính năng gợi ý bạn bè cho mạng xã hội&amp;rdquo;. Ứng viên lập tức nói về microservice, Redis cache, Kafka pipeline, sharding database. Người phỏng vấn ngắt lời bằng một câu hỏi duy nhất: &lt;em>&amp;ldquo;Khoan — &amp;lsquo;bạn của bạn&amp;rsquo; là gì, nói bằng toán?&amp;rdquo;&lt;/em>&lt;/p></description></item><item><title>Chương 03 — Proof Techniques: Vì sao code của bạn đúng</title><link>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/03-proof-techniques/</link><pubDate>Mon, 20 Jul 2026 07:30:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/03-proof-techniques/</guid><description>&lt;blockquote>
&lt;p>Level 1 – Mathematical Thinking
Yêu cầu trước: Chương 01 (Logic), Chương 02 (Set Theory, Functions &amp;amp; Relations)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Năm 1996, tên lửa Ariane 5 nổ tung 37 giây sau khi rời bệ phóng — nửa tỷ đô la bốc hơi vì một phép chuyển đổi số 64-bit sang 16-bit tràn số, trong một module đã chạy hoàn hảo nhiều năm&amp;hellip; trên Ariane 4, nơi giá trị đó &lt;em>không bao giờ&lt;/em> vượt ngưỡng. Code được test kỹ. Test đều pass. Nhưng test chỉ kiểm tra các giá trị &lt;em>đã từng xảy ra&lt;/em>, còn tính đúng đắn là câu khẳng định về &lt;em>mọi&lt;/em> giá trị có thể xảy ra.&lt;/p></description></item><item><title>Chương 02 — Set Theory, Functions &amp; Relations: Ngôn ngữ của dữ liệu</title><link>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/02-set-theory-functions-relations/</link><pubDate>Mon, 20 Jul 2026 07:20:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/02-set-theory-functions-relations/</guid><description>&lt;blockquote>
&lt;p>Level 1 – Mathematical Thinking
Yêu cầu trước: Chương 01 (Logic)&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một kỹ sư viết câu JOIN báo cáo doanh thu theo chi nhánh. Query chạy trên môi trường dev với dữ liệu mẫu: đúng. Đưa lên production: bảng kết quả &lt;strong>phình ra gấp 40 lần&lt;/strong> số dòng thật, tổng doanh thu đội lên tương ứng, và báo cáo gửi CEO sáng hôm sau nói công ty vừa có quý tăng trưởng thần kỳ. Nguyên nhân: điều kiện JOIN thiếu một cột trong khóa ghép — mỗi dòng bảng trái khớp với &lt;em>nhiều&lt;/em> dòng bảng phải, và kết quả trở thành một mảnh của &lt;strong>tích Descartes&lt;/strong> thay vì phép khớp một-một mà tác giả tưởng tượng.&lt;/p></description></item><item><title>Chương 01 — Logic: Nền tảng của mọi dòng code</title><link>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/01-logic/</link><pubDate>Mon, 20 Jul 2026 07:10:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/level-1-mathematical-thinking/01-logic/</guid><description>&lt;blockquote>
&lt;p>Level 1 – Mathematical Thinking
Yêu cầu trước: Không — đây là chương mở đầu của toàn bộ tài liệu&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;h2 id="1-problem-statement">1. Problem Statement&lt;/h2>
&lt;p>Một team backend nhận ticket: &amp;ldquo;Tìm tất cả khách hàng chưa từng đặt hàng để gửi email khuyến mãi&amp;rdquo;. Kỹ sư viết câu SQL trông hoàn toàn hợp lý:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sql" data-lang="sql">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">SELECT&lt;/span> &lt;span style="color:#f92672">*&lt;/span> &lt;span style="color:#66d9ef">FROM&lt;/span> customers
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">WHERE&lt;/span> id &lt;span style="color:#66d9ef">NOT&lt;/span> &lt;span style="color:#66d9ef">IN&lt;/span> (&lt;span style="color:#66d9ef">SELECT&lt;/span> customer_id &lt;span style="color:#66d9ef">FROM&lt;/span> orders);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Query chạy không lỗi, trả về&amp;hellip; &lt;strong>0 dòng&lt;/strong>. Trong khi ai cũng biết có hàng nghìn khách hàng chưa đặt hàng. Không exception, không warning, không log. Nguyên nhân: bảng &lt;code>orders&lt;/code> có &lt;em>một&lt;/em> dòng với &lt;code>customer_id IS NULL&lt;/code> (đơn hàng của khách vãng lai). Và trong logic ba giá trị của SQL, &lt;code>x NOT IN (1, 2, NULL)&lt;/code> không bao giờ là TRUE — với &lt;em>mọi&lt;/em> x.&lt;/p></description></item><item><title>Mathematics for Computer Science &amp; Software Engineering</title><link>https://thanhhv.github.io/series/math-for-engineers/00-muc-luc/</link><pubDate>Mon, 20 Jul 2026 07:00:00 +0700</pubDate><guid>https://thanhhv.github.io/series/math-for-engineers/00-muc-luc/</guid><description>&lt;blockquote>
&lt;p>Toán học không phải là môn học bạn phải &amp;ldquo;vượt qua&amp;rdquo; để trở thành lập trình viên.
Toán học là &lt;strong>ngôn ngữ mô tả và giải quyết vấn đề&lt;/strong> trong Computer Science.&lt;/p>&lt;/blockquote>
&lt;h2 id="tài-liệu-này-dành-cho-ai">Tài liệu này dành cho ai?&lt;/h2>
&lt;p>Software Engineer, Backend Engineer, Frontend Engineer, Fullstack Engineer, AI Engineer, Data Engineer, Senior Developer và Solution Architect — những người muốn hiểu &lt;strong>bản chất toán học&lt;/strong> đằng sau thuật toán, cấu trúc dữ liệu và hệ thống phần mềm, thay vì chỉ học công thức hoặc học thuộc lời giải.&lt;/p></description></item></channel></rss>