Space-Efficient Hierholzer: Eulerian Cycles in O(m) Time and O(n) Space

Abstract

We describe a simple variant of Hierholzer's algorithm that finds an Eulerian cycle in a (multi)graph with n vertices and m edges using O(n m) bits of working memory. This substantially improves the working space compared to standard implementations of Hierholzer's algorithm, which use O(m n) bits of space. Our algorithm runs in linear time, like the classical versions, but avoids an O(m)-size stack of vertices or storing information for each edge. To our knowledge, this is the first linear-time algorithm to achieve this space bound, and the method is very easy to implement. The correctness argument, by contrast, is surprisingly subtle; we give a detailed formal proof. The space savings are particularly relevant for dense graphs or multigraphs with large edge multiplicities.

0

Turn this paper into a full lesson

ArcXiv compiles a staged curriculum from this paper: 8-12 lessons across beginner → advanced, synthesised section guides, visuals, flashcards, a quiz, exercises, and on-demand deep dives per section. Grounded in the abstract, never invented.

Discussion (0)

Sign in to join the discussion.

Loading comments…