English

Longest segment of balanced parentheses -- an exercise in program inversion in a segment problem (Functional Pearl)

Programming Languages 2023-12-01 v2

Abstract

Given a string of parentheses, the task is to find the longest consecutive segment that is balanced, in linear time. We find this problem interesting because it involves a combination of techniques: the usual approach for solving segment problems, and a theorem for constructing the inverse of a function -- through which we derive an instance of shift-reduce parsing.

Keywords

Cite

@article{arxiv.2101.09699,
  title  = {Longest segment of balanced parentheses -- an exercise in program inversion in a segment problem (Functional Pearl)},
  author = {Shin-Cheng Mu and Tsung-Ju Chiang},
  journal= {arXiv preprint arXiv:2101.09699},
  year   = {2023}
}
R2 v1 2026-06-23T22:27:54.716Z