Lowest Common Ancestor LCA in Finite State Machines

What is Lowest Common Ancestor (LCA)? The Lowest Common Ancestor (LCA) of two nodes in a tree is the deepest (i.e., lowest) node that is an ancestor of both nodes. In other words, it is the shared ancestor of the two nodes that is located farthest from the root. The concept is fundamental in computer science, especially in the context of tree data structures, such as binary trees, general trees, and state machines. ...

January 31, 2026 · 3 min · 553 words · Niraj Kashyap

Why Finite State Machines Are Everywhere: From Software to Human Life

Why Finite State Machines Are Everywhere: From Software to Human Life Finite State Machines (FSMs) are everywhere — whether you are writing software, designing systems, or simply living your daily life. From a login screen that moves from “logged out” to “logged in”, to a human being transitioning from “sleeping” to “working”, the same pattern exists. In this article, we’ll explore what a Finite State Machine is, how it works in software, and why human behavior itself can be understood as a series of states and transitions. ...

January 13, 2026 · 3 min · 602 words · Niraj Kashyap

Finite State Machines Backed by PostgreSQL Intro

If you’re new to the concept of Finite State Machines (FSMs), check out my previous blog post: Why Finite State Machines Are Everywhere: From Software to Human Life. That post explores how FSMs are fundamental to both software systems and real-world processes. Finite State Machine: In Various Languages FSMs as a concept have been implemented in many programming languages, each with its own data structures and libraries. For example: TypeScript/JavaScript: xstate is a popular library for modeling FSMs and statecharts. Python: Libraries like transitions provide easy-to-use FSM implementations. Java: Frameworks such as Spring State Machine offer robust FSM support. C#: Libraries like Stateless are widely used for FSMs. Go: Libraries like looplab/fsm provide simple and effective FSM implementations for Go. These libraries use different data structures—objects, classes, state tables, or even domain-specific languages—to represent states and transitions, but the core principles remain the same. ...

December 30, 2025 · 3 min · 580 words · Niraj Kashyap