Cycle Detection:Directed, Undirected, and the Color/Parent Trick
Detect a directed cycle with 3-color DFS (gray means on the recursion stack) and an undirected cycle by skipping the parent — a visited flag alone is the diamond trap.
Read MoreBrowse the full archive. Use topics in the sidebar to explore by tag.
Detect a directed cycle with 3-color DFS (gray means on the recursion stack) and an undirected cycle by skipping the parent — a visited flag alone is the diamond trap.
Read MoreSpot Liskov Substitution violations in Java inheritance — UnsupportedOperationException, tightened preconditions, null surprises — and replace dishonest subtypes with honest types.
Read MoreWalk a graph with DFS, stamp finish times, run the same walk on an ArrayDeque, and recognize a back edge as the shape of a cycle.
Read MoreApply the Open-Closed Principle in Java: replace growing if/switch payment forests with extension seams so new providers are added, not edited into the core.
Read MoreWhat the Single Responsibility Principle actually means — one audience, one reason to change — with a Java OrderProcessor god class split into cohesive pieces.
Read MoreHands-on triage with htop, journalctl, dmesg, and lsof — diagnose high load and crashes by chaining the right tool at each step.
Read MoreWhat SOLID means in practice, a glossary of the five principles, when they become cargo-cult, and a map of this series — with a shared order/payment domain for later posts.
Read MoreUse Collection.stream, parallelStream, spliterator characteristics, and Collectors.toCollection to leave a collection and land in the right one — without re-teaching Stream.map.
Read MoreVisit vertices in hop order with a FIFO queue — level order and unweighted shortest path — and see why a stack is the wrong frontier.
Read MoreHands-on batch editing on the command line — find the right files, feed them safely through xargs, and rewrite them with sed.
Read More