Table of Contents
Fetching ...

Permutation Matching Under Parikh Budgets: Linear-Time Detection, Packing, and Disjoint Selection

MD Nazmul Alam Shanto, Md. Tanzeem Rahat, Md. Manzurul Hasan

TL;DR

This work studies permutation (jumbled/Abelian) pattern matching on a general alphabet by introducing a concise sliding-window framework that maintains the Parikh-vector difference. The approach yields a linear-time, $O(n+\sigma)$-space method for exact permutation matching and extends to two optimization variants: MFSP, which finds the longest substring under a Parikh budget in $O(n+\sigma)$ time, and a linear-time strategy for selecting a maximum number of non-overlapping matches via interval packing. The results connect frequency-based string matching with packing-like optimization primitives and are complemented by experimental observations highlighting practical efficiency and implementation considerations such as alphabet compression. Together, these contributions provide provably correct, tight-bound algorithms for detection, packing under budgets, and disjoint selection in permutation matching, with implications for resource-constrained pattern searching and fast scanning pipelines.

Abstract

We study permutation (jumbled/Abelian) pattern matching over a general alphabet $Σ$. Given a pattern P of length m and a text T of length n, the classical task is to decide whether T contains a length-m substring whose Parikh vector equals that of P . While this existence problem admits a linear-time sliding-window solution, many practical applications require optimization and packing variants beyond mere detection. We present a unified sliding-window framework based on maintaining the Parikh-vector difference between P and the current window of T , enabling permutation matching in O(n + σ) time and O(σ) space, where σ = |Σ|. Building on this foundation, we introduce a combinatorial-optimization variant that we call Maximum Feasible Substring under Pattern Supply (MFSP): find the longest substring S of T whose symbol counts are component-wise bounded by those of P . We show that MFSP can also be solved in O(n + σ) time via a two-pointer feasibility maintenance algorithm, providing an exact packing interpretation of P as a resource budget. Finally, we address non-overlapping occurrence selection by modeling each permutation match as an equal-length interval and proving that a greedy earliest-finishing strategy yields a maximum-cardinality set of disjoint matches, computable in linear time once all matches are enumerated. Our results provide concise, provably correct algorithms with tight bounds, and connect frequency-based string matching to packing-style optimization primitives.

Permutation Matching Under Parikh Budgets: Linear-Time Detection, Packing, and Disjoint Selection

TL;DR

This work studies permutation (jumbled/Abelian) pattern matching on a general alphabet by introducing a concise sliding-window framework that maintains the Parikh-vector difference. The approach yields a linear-time, -space method for exact permutation matching and extends to two optimization variants: MFSP, which finds the longest substring under a Parikh budget in time, and a linear-time strategy for selecting a maximum number of non-overlapping matches via interval packing. The results connect frequency-based string matching with packing-like optimization primitives and are complemented by experimental observations highlighting practical efficiency and implementation considerations such as alphabet compression. Together, these contributions provide provably correct, tight-bound algorithms for detection, packing under budgets, and disjoint selection in permutation matching, with implications for resource-constrained pattern searching and fast scanning pipelines.

Abstract

We study permutation (jumbled/Abelian) pattern matching over a general alphabet . Given a pattern P of length m and a text T of length n, the classical task is to decide whether T contains a length-m substring whose Parikh vector equals that of P . While this existence problem admits a linear-time sliding-window solution, many practical applications require optimization and packing variants beyond mere detection. We present a unified sliding-window framework based on maintaining the Parikh-vector difference between P and the current window of T , enabling permutation matching in O(n + σ) time and O(σ) space, where σ = |Σ|. Building on this foundation, we introduce a combinatorial-optimization variant that we call Maximum Feasible Substring under Pattern Supply (MFSP): find the longest substring S of T whose symbol counts are component-wise bounded by those of P . We show that MFSP can also be solved in O(n + σ) time via a two-pointer feasibility maintenance algorithm, providing an exact packing interpretation of P as a resource budget. Finally, we address non-overlapping occurrence selection by modeling each permutation match as an equal-length interval and proving that a greedy earliest-finishing strategy yields a maximum-cardinality set of disjoint matches, computable in linear time once all matches are enumerated. Our results provide concise, provably correct algorithms with tight bounds, and connect frequency-based string matching to packing-style optimization primitives.
Paper Structure (29 sections, 6 theorems, 14 equations, 4 figures, 3 algorithms)

This paper contains 29 sections, 6 theorems, 14 equations, 4 figures, 3 algorithms.

Key Result

theorem thmcountertheorem

Algorithm alg:perm returns True if and only if there exists an index $i$ with $0\le i\le n-m$ such that $\mathrm{freq}(W_i)=\mathrm{freq}(P)$.

Figures (4)

  • Figure 1: Two viewpoints used in this paper. Top: permutation matching asks whether some length-$m$ window $W_i$ has the same Parikh vector as $P$. Bottom: treating $\mathrm{freq}(P)$ as a supply vector yields a packing-style feasibility constraint for selecting long substrings under symbol budgets.
  • Figure 2: Notation: a length-$m$ window $W_i$ slides over $T$. Maintaining the Parikh-difference vector $\Delta_i$ and the nonzero counter $nz_i$ allows constant-time updates per shift.
  • Figure 3: MFSP maintains a feasible window under the supply vector $\mathrm{sup}=\mathrm{freq}(P)$. When the window becomes infeasible, the left pointer advances until feasibility is restored.
  • Figure 4: Non-overlapping selection after enumerating all matches. Each match is a length-$m$ interval; greedy chooses the leftmost available interval and skips ahead by $m$, yielding a maximum-size disjoint set for equal-length intervals.

Theorems & Definitions (12)

  • theorem thmcountertheorem
  • proof
  • theorem thmcountertheorem
  • proof
  • theorem thmcountertheorem
  • proof
  • theorem thmcountertheorem
  • proof
  • theorem thmcountertheorem
  • proof
  • ...and 2 more