#
Combinatorial Generation Algorithms for Some Lattice Paths Using the Method Based on AND/OR Trees^{ †}

^{†}

## Abstract

**:**

## 1. Introduction

- Listing: the sequential generation of all objects belonging to the combinatorial set;
- Ranking: the assignment of an individual number (a rank) to an object belonging to the combinatorial set (this requires some way to order the elements of the combinatorial set);
- Unranking: the generation of an object belonging to the combinatorial set by the value of its rank (this requires some way to order the elements of the combinatorial set);
- Random selection: the generation of random objects belonging to the combinatorial set.

## 2. Materials and Methods

## 3. Results

#### 3.1. Combinatorial Generation Algorithms for North-East Lattice Paths

#### 3.1.1. Combinatorial Set

#### 3.1.2. AND/OR Tree Structure

- Each node labeled ${L}_{n}^{0}$ is a leaf node in the AND/OR tree for ${L}_{n}^{m}$;
- Each node labeled ${L}_{0}^{m}$ is a leaf node in the AND/OR tree for ${L}_{n}^{m}$.

**Theorem 1.**

**Proof.**

- Each selected left child of the OR node labeled ${L}_{n}^{m}$ determines the addition of one North-step to the North-East lattice path obtained by the subtree of the node labeled ${L}_{n}^{m-1}$: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{n+m-1},N\right)$;
- Each selected right child of the OR node labeled ${L}_{n}^{m}$ determines the addition of one East-step to the North-East lattice path obtained by the subtree of the node labeled ${L}_{n-1}^{m}$: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{n+m-1},E\right)$;
- Each leaf node labeled ${L}_{n}^{0}$ determines the lattice path from $(0,0)$ to $(n,0)$ that consists of n East-steps: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{n}\right)=\left(E,\dots ,E\right)$;
- Each leaf node labeled ${L}_{0}^{m}$ determines the lattice path from $(0,0)$ to $(0,m)$ that consists of m North-steps: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{m}\right)=\left(N,\dots ,N\right)$.

#### 3.1.3. Ranking and Unranking Algorithms

Algorithm 1: An algorithm for ranking a variant of the AND/OR tree for ${L}_{n}^{m}$. |

Algorithm 2: An algorithm for unranking a variant of the AND/OR tree for ${L}_{n}^{m}$. |

- Algorithm 1 has at most m recursive calls where ${v}_{1}=1$ (each such recursive call requires one assignment) and has at most n recursive calls where ${v}_{1}=2$ (each such recursive call requires calculations of ${L}_{n}^{m-1}$). Applying Equation (1), the calculation of ${L}_{n}^{m}$ has linear time complexity $O\left(m\right)$ for $m<n$ and $O\left(n\right)$ for $m>n$. Hence, Algorithm 1 has polynomial time complexity $O\left(nm\right)$ for $m<n$ and $O(m+{n}^{2})$ for $m>n$;
- Algorithm 2 has at most $(n+m)$ recursive calls where each such recursive call requires calculations of ${L}_{n}^{m-1}$. Hence, Algorithm 2 has polynomial time complexity $O\left(m\right(n+\phantom{\rule{3.33333pt}{0ex}}m\left)\right)$ for $m<n$ and $O\left(n\right(n+m\left)\right)$ for $m>n$.

#### 3.2. Combinatorial Generation Algorithms for Dyck Paths

#### 3.2.1. Combinatorial Set

#### 3.2.2. AND/OR Tree Structure

- Each node labeled ${C}_{0}$ is a leaf node in the AND/OR tree for ${C}_{n}$.

- An empty sequence $v=\left(\right)$ corresponds to the selection of a leaf node labeled ${C}_{0}$;
- I corresponds to the selected value of i in the AND/OR tree for ${C}_{n}$;
- ${v}_{1}$ corresponds to the variant of the subtree of the node labeled ${C}_{I}$ (the left subtree);
- ${v}_{2}$ corresponds to the variant of the subtree of the node labeled ${C}_{n-1-I}$ (the right subtree).

**Theorem 2.**

**Proof.**

- Each selected child of the OR node labeled ${C}_{n}$ determines the addition of one East-step and one North-step to the Dyck $(n-1)$-path that merges the Dyck I-path obtained by the subtree of the node labeled ${C}_{I}$ and consisting of $2I$ steps and the Dyck $(n-1-I)$-path obtained by the subtree of the node labeled ${C}_{n-1-I}$ and consisting of $(2n-2I-2)$ steps: the resulting Dyck n-path is $\left({s}_{1},\dots ,{s}_{2I},E,{s}_{2I+2},\dots ,{s}_{2n-1},N\right)$;
- The subtree of the node labeled ${C}_{I}$ (the left subtree) determines the Dyck I-path of the form $\left({s}_{1},\dots ,{s}_{2I}\right)$;
- The subtree of the node labeled ${C}_{n-1-I}$ (the right subtree) determines the Dyck $(n-1-I)$-path of the form $\left({s}_{2I+2},\dots ,{s}_{2n-1}\right)$;
- Each leaf node labeled ${C}_{0}$ determines the empty lattice path.

#### 3.2.3. Ranking and Unranking Algorithms

- Algorithm 3 has at most n recursive calls, where each such recursive call requires calculations of ${C}_{n}$ maximum $(2n-1)$ times. Applying Equation (3), the calculation of ${C}_{n}$ has linear time complexity $O\left(n\right)$. Hence, Algorithm 3 has polynomial time complexity $O\left({n}^{3}\right)$;
- Algorithm 4 has at most n recursive calls, where each such recursive call requires calculations of ${C}_{n}$ maximum $(2n+1)$ times. Hence, Algorithm 4 has polynomial time complexity $O\left({n}^{3}\right)$.

Algorithm 3: An algorithm for ranking a variant of the AND/OR tree for ${C}_{n}$. |

Algorithm 4: An algorithm for unranking a variant of the AND/OR tree for ${C}_{n}$. |

#### 3.3. Combinatorial Generation Algorithms for Delannoy Paths

#### 3.3.1. Combinatorial Set

#### 3.3.2. AND/OR Tree Structure

- Each node labeled ${D}_{n}^{0}$ is a leaf node in the AND/OR tree for ${D}_{n}^{m}$;
- Each node labeled ${D}_{0}^{m}$ is a leaf node in the AND/OR tree for ${D}_{n}^{m}$.

**Theorem 3.**

**Proof.**

- Each selected left child of the OR node labeled ${D}_{n}^{m}$ determines the addition of one North-step to the Delannoy path obtained by the subtree of the node labeled ${D}_{n}^{m-1}$ and consisting of k steps: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{k},N\right)$;
- Each selected middle child of the OR node labeled ${D}_{n}^{m}$ determines the addition of one East-step to the Delannoy path obtained by the subtree of the node labeled ${D}_{n-1}^{m}$ and consisting of k steps: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{k},E\right)$;
- Each selected right child of the OR node labeled ${D}_{n}^{m}$ determines the addition of one North-East-step to the Delannoy path obtained by the subtree of the node labeled ${D}_{n-1}^{m-1}$ and consisting of k steps: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{k},NE\right)$;
- Each leaf node labeled ${D}_{n}^{0}$ determines the Delannoy path from $(0,0)$ to $(n,0)$ that consists of n East-steps: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{n}\right)=\left(E,\dots ,E\right)$;
- Each leaf node labeled ${D}_{0}^{m}$ determines the Delannoy path from $(0,0)$ to $(0,m)$ that consists of m North-steps: the resulting lattice path is $\left({s}_{1},\dots ,{s}_{m}\right)=\left(N,\dots ,N\right)$.

#### 3.3.3. Ranking and Unranking Algorithms

Algorithm 5: An algorithm for ranking a variant of the AND/OR tree for ${D}_{n}^{m}$. |

Algorithm 6: An algorithm for unranking a variant of the AND/OR tree for ${D}_{n}^{m}$. |

- Algorithm 5 has at most m recursive calls where ${v}_{1}=1$ (each such recursive call requires one assignment), has at most n recursive calls where ${v}_{1}=2$ (each such recursive call requires calculations of ${D}_{n}^{m-1}$), and has at most $min(n,m)$ recursive calls where ${v}_{1}=3$ (each such recursive call requires calculations of ${D}_{n}^{m-1}$ and ${D}_{n-1}^{m}$). Applying Equation (5), the calculation of ${D}_{n}^{m}$ has polynomial time complexity $O\left({m}^{2}\right)$ for $m<n$ and $O\left({n}^{2}\right)$ for $m>n$. Hence, Algorithm 5 has polynomial time complexity $O\left({m}^{2}(n+m)\right)$ for $m<n$ and $O(m+{n}^{3})$ for $m>n$;
- Algorithm 6 has at most $(n+m)$ recursive calls where each such recursive call requires calculations of ${D}_{n}^{m-1}$ or ${D}_{n-1}^{m}$. Hence, Algorithm 2 has polynomial time complexity $O\left({m}^{2}(n+m)\right)$ for $m<n$ and $O\left({n}^{2}(n+m)\right)$ for $m>n$.

#### 3.4. Combinatorial Generation Algorithms for Schroder Paths

#### 3.4.1. Combinatorial Set

#### 3.4.2. AND/OR Tree Structure

- Each node labeled ${S}_{0}$ is a leaf node in the AND/OR tree for ${S}_{n}$.

- If the left child of the OR nodde labeled ${S}_{n}$ is selected, then $v=(I,{v}_{1})$, where
- $I=-1$;
- ${v}_{1}$ corresponds to the variant of the subtree of the node labeled ${S}_{n-1}$;

- Otherwise $v=(I,{v}_{1},{v}_{2})$, where
- I corresponds to the selected value of i in the AND/OR tree for ${S}_{n}$;
- ${v}_{1}$ corresponds to the variant of the subtree of the node labeled ${S}_{I}$;
- ${v}_{2}$ corresponds to the variant of the subtree of the node labeled ${S}_{n-1-I}$;

- An empty sequence $v=\left(\right)$ corresponds to the selection of a leaf node labeled ${S}_{0}$.

**Theorem 4.**

**Proof.**

- Each selected left child of the OR node labeled ${S}_{n}$ determines the addition of one North-East-step to the Schroder $(n-1)$-path obtained by the subtree of the node labeled ${S}_{n-1}$ and consisting of k steps: the resulting Schroder n-path is $\left({s}_{1},\dots ,{s}_{k},NE\right)$;
- Each selected child of the OR node labeled ${S}_{n}$ determines the addition of one East-step and one North-step to the Schroder $(n-1)$-path that merges the Schroder I-path obtained by the subtree of the node labeled ${S}_{I}$ and consisting of ${k}_{1}$ steps and the Schroder $(n-1-I)$-path obtained by the subtree of the node labeled ${S}_{n-1-I}$ and consisting of ${k}_{2}$ steps: the resulting Schroder n-path is $\left({s}_{1},\dots ,{s}_{{k}_{1}},E,{s}_{{k}_{1}+2},\dots ,{s}_{{k}_{1}+1+{k}_{2}},N\right)$;
- The subtree of the node labeled ${S}_{I}$ (the left subtree) determines the Schroder I-path of the form $\left({s}_{1},\dots ,{s}_{{k}_{1}}\right)$;
- The subtree of the node labeled ${S}_{n-1-I}$ (the right subtree) determines the Schroder $(n-1-I)$-path of the form $\left({s}_{{k}_{1}+2},\dots ,{s}_{{k}_{1}+1+{k}_{2}}\right)$;
- Each leaf node labeled ${S}_{0}$ determines the empty lattice path ().

#### 3.4.3. Ranking and Unranking Algorithms

- Algorithm 7 has at most n recursive calls where $I=-1$ (each such recursive call requires one assignment) and has at most n recursive calls where $I\ne -1$ (each such recursive call requires calculations of ${S}_{n}$ maximum $2n$ times). Applying Equation (7), the calculation of ${S}_{n}$ has polynomial time complexity $O\left({n}^{2}\right)$. Hence, Algorithm 7 has polynomial time complexity $O\left({n}^{4}\right)$;
- Algorithm 8 has at most n recursive calls where $I=-1$ (each such recursive call requires calculations of ${S}_{n}$) and has at most n recursive calls where $I\ne -1$ (each such recursive call requires calculations of ${S}_{n}$ maximum $(2n+2)$ times). Hence, Algorithm 8 has polynomial time complexity $O\left({n}^{4}\right)$.

Algorithm 7: An algorithm for ranking a variant of the AND/OR tree for ${S}_{n}$. |

Algorithm 8: An algorithm for unranking a variant of the AND/OR tree for ${S}_{n}$. |

#### 3.5. Combinatorial Generation Algorithms for Motzkin Paths

#### 3.5.1. Combinatorial Set

#### 3.5.2. AND/OR Tree Structure

- each node labeled ${M}_{0}$ or ${M}_{1}$ is a leaf node in the AND/OR tree for ${M}_{n}$.

- If the left child of the OR node labeled ${M}_{n}$ is selected, then $v=(I,{v}_{1})$, where
- $I=-1$;
- ${v}_{1}$ corresponds to the variant of the subtree of the node labeled ${M}_{n-1}$;

- Otherwise $v=(I,{v}_{1},{v}_{2})$, where
- I corresponds to the selected value of i in the AND/OR tree for ${M}_{n}$;
- ${v}_{1}$ corresponds to the variant of the subtree of the node labeled ${M}_{I}$;
- ${v}_{2}$ corresponds to the variant of the subtree of the node labeled ${M}_{n-2-I}$;

- An empty sequence $v=\left(\right)$ corresponds to the selection of a leaf node labeled ${M}_{0}$.

**Theorem 5.**

**Proof.**

- each selected left child of the OR node labeled ${M}_{n}$ determines the addition of one North-East-step to the Motzkin $(n-1)$-path obtained by the subtree of the node labeled ${M}_{n-1}$ and consisting of k steps: the resulting Motzkin n-path is $\left({s}_{1},\dots ,{s}_{k},NE\right)$;
- each selected child of the OR node labeled ${M}_{n}$ determines the addition of two East-steps and North-steps to the Motzkin $(n-2)$-path that merges the Motzkin I-path obtained by the subtree of the node labeled ${M}_{I}$ and consisting of ${k}_{1}$ steps and the Motzkin $(n-2-I)$-path obtained by the subtree of the node labeled ${M}_{n-2-I}$ and consisting of ${k}_{2}$ steps: the resulting Motzkin n-path is $\left({s}_{1},\dots ,{s}_{{k}_{1}},E,E,{s}_{{k}_{1}+3},\dots ,{s}_{{k}_{1}+2+{k}_{2}},N,N\right)$;
- the subtree of the node labeled ${M}_{I}$ (the left subtree) determines the Motzkin I-path of the form $\left({s}_{1},\dots ,{s}_{{k}_{1}}\right)$;
- the subtree of the node labeled ${M}_{n-2-I}$ (the right subtree) determines the Motzkin $(n-2-I)$-path of the form $\left({s}_{{k}_{1}+3},\dots ,{s}_{{k}_{1}+2+{k}_{2}}\right)$;
- each leaf node labeled ${M}_{1}$ determines the lattice path from $(0,0)$ to $(1,1)$ that consists of one North-East-step: the resulting lattice path is $\left({s}_{1}\right)=\left(NE\right)$;
- each leaf node labeled ${M}_{0}$ determines the empty lattice path ().

#### 3.5.3. Ranking and Unranking Algorithms

- Algorithm 9 has at most n recursive calls where $I=-1$ (each such recursive call requires one assignment) and has at most n recursive calls where $I\ne -1$ (each such recursive call requires calculations of ${M}_{n}$ maximum $(2n-2)$ times). Applying Equation (9), the calculation of ${M}_{n}$ has polynomial time complexity $O\left({n}^{2}\right)$. Hence, Algorithm 9 has polynomial time complexity $O\left({n}^{4}\right)$;
- Algorithm 10 has at most n recursive calls where $I=-1$ (each such recursive call requires calculations of ${M}_{n}$) and has at most n recursive calls where $I\ne -1$ (each such recursive call requires calculations of ${M}_{n}$ maximum $2n$ times). Hence, Algorithm 10 has polynomial time complexity $O\left({n}^{4}\right)$.

Algorithm 9: An algorithm for ranking a variant of the AND/OR tree for ${M}_{n}$. |

Algorithm 10: An algorithm for unranking a variant of the AND/OR tree for ${M}_{n}$. |

#### 3.6. Computational Experiments

## 4. Discussion

- By calculating $sum$ (for example, see Line 5 in Algorithm 3 or Lines 5–14 in Algorithm 4), applying a simpler explicit formula without using the summation operator;
- By a preliminary search of the value of the selected child of the OR node (for example, the parameter I defined in Lines 6–14 in Algorithm 4), applying an approximate formula (as in [26]).

## Funding

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## References

- Kreher, D.L.; Stinson, D.R. Combinatorial Algorithms: Generation, Enumeration, and Search; CRC Press: Boca Raton, FL, USA, 1999. [Google Scholar]
- Ruskey, F. Combinatorial Generation. Available online: https://page.math.tu-berlin.de/~felsner/SemWS17-18/Ruskey-Comb-Gen.pdf (accessed on 1 May 2023).
- Knuth, D.E. The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1; Addison-Wesley Professional: Boston, MA, USA, 2011. [Google Scholar]
- Stanley, R.P. Enumerative Combinatorics: Volume 1, 2nd ed.; Cambridge University Press: New York, NY, USA, 2012. [Google Scholar]
- Wallner, M. Combinatorics of Lattice Paths and Tree-Like Structures. Ph.D. Thesis, Institute of Discrete Mathematics and Geometry, Vienna University of Technology, Vienna, Austria, 2016. [Google Scholar]
- Humphreys, K. A history and a survey of lattice path enumeration. J. Statist. Plann. Inference
**2010**, 140, 2237–2254. [Google Scholar] [CrossRef] - Krattenthaler, C. Lattice path enumeration. In Handbook of Enumerative Combinatorics; Bona, M., Ed.; CRC Press: New York, NY, USA, 2015; pp. 589–678. [Google Scholar]
- Zaks, S.; Richards, D. Generating trees and other combinatorial objects lexicographically. SIAM J. Comput.
**1979**, 8, 73–81. [Google Scholar] [CrossRef] - Bent, S.W. Ranking trees generated by rotations. Lect. Notes Comput. Sci.
**1990**, 447, 132–142. [Google Scholar] - Parque, V.; Miyashita, T. An efficient scheme for the generation of ordered trees in constant amortized time. In Proceedings of the 15th International Conference on Ubiquitous Information Management and Communication (IMCOM), Seoul, Republic of Korea, 4–6 January 2021. [Google Scholar]
- Barcucci, E.; Bernini, A.; Pinzani, R. Exhaustive generation of positive lattice paths. In Proceedings of the 11th International Conference on Random and Exhaustive Generation of Combinatorial Structures (GASCom), Athens, Greece, 18–20 June 2018. [Google Scholar]
- Barcucci, E.; Bernini, A.; Pinzani, R. Exhaustive generation of some lattice paths and their prefixes. Theoret. Comput. Sci.
**2021**, 878–879, 47–52. [Google Scholar] [CrossRef] - Kuo, T. From enumerating to generating: A linear time algorithm for generating 2D lattice paths with a given number of turns. Algorithms
**2015**, 8, 190–208. [Google Scholar] [CrossRef] - The Combinatorial Object Server. Available online: http://combos.org/ (accessed on 1 May 2023).
- Barcucci, E.; Del Lungo, A.; Pergola, E.; Pinzani, R. ECO: A methodology for the enumeration of combinatorial objects. J. Differ. Equ. Appl.
**1999**, 5, 435–490. [Google Scholar] [CrossRef] - Flajolet, P.; Zimmerman, P.; Cutsem, B. A calculus for the random generation of combinatorial structures. Theoret. Comput. Sci.
**1994**, 132, 1–35. [Google Scholar] [CrossRef] - Shablya, Y.; Kruchinin, D.; Kruchinin, V. Method for developing combinatorial generation algorithms based on AND/OR trees and its application. Mathematics
**2020**, 8, 962. [Google Scholar] [CrossRef] - Shablya, Y.; Tokareva, A. Development of combinatorial generation algorithms for some lattice paths using the method based on AND/OR trees. In Proceedings of the 5th Mediterranean International Conference of Pure & Applied Mathematics and Related Areas (MICOPAM), Antalya, Turkey, 27–30 October 2022. [Google Scholar]
- Mohanty, G. Lattice Path Counting and Applications; Academic Press: New York, NY, USA, 1979. [Google Scholar]
- The On-Line Encyclopedia of Integer Sequences. Available online: https://oeis.org/ (accessed on 1 May 2023).
- Mansour, T. Statistics on Dyck paths. J. Integer Seq.
**2005**, 9, 06.1.5. [Google Scholar] - Banderier, C.; Schwer, S. Why Delannoy numbers? J. Statist. Plann. Inference
**2005**, 135, 40–54. [Google Scholar] [CrossRef] - Shapiro, L.W.; Sulanke, R.A. Bijections for the Schroder numbers. Math. Mag.
**2000**, 73, 369–376. [Google Scholar] [CrossRef] - Oste, R.; Van der Jeugt, J. Motzkin paths, Motzkin polynomials and recurrence relations. Electron. J. Combin.
**2015**, 22, P2.8. [Google Scholar] [CrossRef] [PubMed] - Maxima, a Computer Algebra System. Available online: https://maxima.sourceforge.io/ (accessed on 1 May 2023).
- Kruchinin, V.; Shablya, Y.; Kruchinin, D. Unranking small combinations of a large set in co-lexicographic order. Algorithms
**2022**, 15, 36. [Google Scholar] [CrossRef] - Deutsch, E.; Munarini, E.; Rinaldi, R. Skew Dyck paths. J. Statist. Plann. Inference
**2010**, 140, 2191–2203. [Google Scholar] [CrossRef] - Prodinger, H. Skew Dyck paths with catastrophes. Discrete Math. Lett.
**2022**, 10, 9–13. [Google Scholar] - Kruchinin, D.; Kruchinin, V.; Shablya, Y. On some properties of generalized Narayana numbers. Quaest. Math.
**2022**, 45, 1949–1963. [Google Scholar] [CrossRef]

**Figure 16.**Average time for unranking (

**blue**) and ranking (

**red**) variants of the AND/OR tree for ${L}_{n}^{m}$: (

**a**) dependence on n when $m=100$; and (

**b**) dependence on m when $n=100$.

**Figure 17.**Average time for unranking (

**blue**) and ranking (

**red**) variants of the AND/OR tree for ${C}_{n}$.

**Figure 18.**Average time for unranking (

**blue**) and ranking (

**red**) variants of the AND/OR tree for ${D}_{n}^{m}$: (

**a**) dependence on n when $m=50$; and (

**b**) dependence on m when $n=50$.

**Figure 19.**Average time for unranking (

**blue**) and ranking (

**red**) variants of the AND/OR tree for ${S}_{n}$.

**Figure 20.**Average time for unranking (

**blue**) and ranking (

**red**) variants of the AND/OR tree for ${M}_{n}$.

Lattice Path | Variant of AND/OR Tree | Rank |
---|---|---|

$E,E,E,N,N,N$ | $(1,1,1)$ | 0 |

$E,E,N,E,N,N$ | $(1,1,2,1)$ | 1 |

$E,N,E,E,N,N$ | $(1,1,2,2,1)$ | 2 |

$N,E,E,E,N,N$ | $(1,1,2,2,2)$ | 3 |

$E,E,N,N,E,N$ | $(1,2,1,1)$ | 4 |

$E,N,E,N,E,N$ | $(1,2,1,2,1)$ | 5 |

$N,E,E,N,E,N$ | $(1,2,1,2,2)$ | 6 |

$E,N,N,E,E,N$ | $(1,2,2,1,1)$ | 7 |

$N,E,N,E,E,N$ | $(1,2,2,1,2)$ | 8 |

$N,N,E,E,E,N$ | $(1,2,2,2)$ | 9 |

$E,E,N,N,N,E$ | $(2,1,1,1)$ | 10 |

$E,N,E,N,N,E$ | $(2,1,1,2,1)$ | 11 |

$N,E,E,N,N,E$ | $(2,1,1,2,2)$ | 12 |

$E,N,N,E,N,E$ | $(2,1,2,1,1)$ | 13 |

$N,E,N,E,N,E$ | $(2,1,2,1,2)$ | 14 |

$N,N,E,E,N,E$ | $(2,1,2,2)$ | 15 |

$E,N,N,N,E,E$ | $(2,2,1,1,1)$ | 16 |

$N,E,N,N,E,E$ | $(2,2,1,1,2)$ | 17 |

$N,N,E,N,E,E$ | $(2,2,1,2)$ | 18 |

$N,N,N,E,E,E$ | $(2,2,2)$ | 19 |

Lattice Path | Variant of AND/OR Tree | Rank |
---|---|---|

$E,E,E,N,N,N$ | $(0,(),(0,\left(\right),(0,(),(\left)\right)\left)\right)$ | 0 |

$E,E,N,E,N,N$ | $(0,(),(1,(0,(),(\left)\right),\left(\right)\left)\right)$ | 1 |

$E,N,E,E,N,N$ | $(1,(0,\left(\right),\left(\right)),(0,\left(\right),\left(\right)\left)\right)$ | 2 |

$E,E,N,N,E,N$ | $(2,(0,\left(\right),(0,(),(\left)\right)),(\left)\right)$ | 3 |

$E,N,E,N,E,N$ | $(2,(1,(0,(),(\left)\right),\left(\right)),(\left)\right)$ | 4 |

Lattice Path | Variant of AND/OR Tree | Rank |
---|---|---|

$E,E,E,N,N$ | $(1,1)$ | 0 |

$E,E,N,E,N$ | $(1,2,1)$ | 1 |

$E,N,E,E,N$ | $(1,2,2,1)$ | 2 |

$N,E,E,E,N$ | $(1,2,2,2)$ | 3 |

$NE,E,E,N$ | $(1,2,2,3)$ | 4 |

$E,NE,E,N$ | $(1,2,3)$ | 5 |

$E,E,NE,N$ | $(1,3)$ | 6 |

$E,E,N,N,E$ | $(2,1,1)$ | 7 |

$E,N,E,N,E$ | $(2,1,2,1)$ | 8 |

$N,E,E,N,E$ | $(2,1,2,2)$ | 9 |

$NE,E,N,E$ | $(2,1,2,3)$ | 10 |

$E,NE,N,E$ | $(2,1,3)$ | 11 |

$E,N,N,E,E$ | $(2,2,1,1)$ | 12 |

$N,E,N,E,E$ | $(2,2,1,2)$ | 13 |

$NE,N,E,E$ | $(2,2,1,3)$ | 14 |

$N,N,E,E,E$ | $(2,2,2)$ | 15 |

$N,NE,E,E$ | $(2,2,3)$ | 16 |

$E,N,NE,E$ | $(2,3,1)$ | 17 |

$N,E,NE,E$ | $(2,3,2)$ | 18 |

$NE,NE,E$ | $(2,3,3)$ | 19 |

$E,E,N,NE$ | $(3,1)$ | 20 |

$E,N,E,NE$ | $(3,2,1)$ | 21 |

$N,E,E,NE$ | $(3,2,2)$ | 22 |

$NE,E,NE$ | $(3,2,3)$ | 23 |

$E,NE,NE$ | $(3,3)$ | 24 |

Lattice Path | Variant of AND/OR Tree | Rank |
---|---|---|

$NE,NE,NE$ | $(-1,(-1,(-1,(\left)\right)\left)\right)$ | 0 |

$E,N,NE,NE$ | $(-1,(-1,(0,(),(\left)\right)\left)\right)$ | 1 |

$E,NE,N,NE$ | $(-1,(0,\left(\right),(-1,(\left)\right)\left)\right)$ | 2 |

$E,E,N,N,NE$ | $(-1,(0,\left(\right),(0,(),(\left)\right)\left)\right)$ | 3 |

$NE,E,N,NE$ | $(-1,(1,(-1,(\left)\right),\left(\right)\left)\right)$ | 4 |

$E,N,E,N,NE$ | $(-1,(1,(0,(),(\left)\right),\left(\right)\left)\right)$ | 5 |

$E,NE,NE,N$ | $(0,(),(-1,(-1,(\left)\right)\left)\right)$ | 6 |

$E,E,N,NE,N$ | $(0,(),(-1,(0,(),(\left)\right)\left)\right)$ | 7 |

$E,E,NE,N,N$ | $(0,(),(0,\left(\right),(-1,(\left)\right)\left)\right)$ | 8 |

$E,E,E,N,N,N$ | $(0,(),(0,\left(\right),(0,(),(\left)\right)\left)\right)$ | 9 |

$E,NE,E,N,N$ | $(0,(),(1,(-1,(\left)\right),\left(\right)\left)\right)$ | 10 |

$E,E,N,E,N,N$ | $(0,(),(1,(0,(),(\left)\right),\left(\right)\left)\right)$ | 11 |

$NE,E,NE,N$ | $(1,(-1,\left(\right)),(-1,\left(\right)\left)\right)$ | 12 |

$E,N,E,NE,N$ | $(1,(0,\left(\right),\left(\right)),(-1,\left(\right)\left)\right)$ | 13 |

$NE,E,E,N,N$ | $(1,(-1,\left(\right)),(0,\left(\right),\left(\right)\left)\right)$ | 14 |

$E,N,E,E,N,N$ | $(1,(0,\left(\right),\left(\right)),(0,\left(\right),\left(\right)\left)\right)$ | 15 |

$NE,NE,E,N$ | $(2,(-1,(-1,(\left)\right)),(\left)\right)$ | 16 |

$E,N,NE,E,N$ | $(2,(-1,(0,(),(\left)\right)),(\left)\right)$ | 17 |

$E,NE,N,E,N$ | $(2,(0,\left(\right),(-1,(\left)\right)),(\left)\right)$ | 18 |

$E,E,N,N,E,N$ | $(2,(0,\left(\right),(0,(),(\left)\right)),(\left)\right)$ | 19 |

$NE,E,N,E,N$ | $(2,(1,(-1,(\left)\right),\left(\right)),(\left)\right)$ | 20 |

$E,N,E,N,E,N$ | $(2,(1,(0,(),(\left)\right),\left(\right)),(\left)\right)$ | 21 |

Lattice path | Variant of AND/OR tree | Rank |
---|---|---|

$NE,NE,NE$ | $(-1,(-1,(-1,(\left)\right)\left)\right)$ | 0 |

$E,E,N,N,NE$ | $(-1,(0,\left(\right),\left(\right)\left)\right)$ | 1 |

$E,E,NE,N,N$ | $(0,(),(-1,\left(\right)\left)\right)$ | 2 |

$NE,E,E,N,N$ | $(1,(-1,\left(\right)),(\left)\right)$ | 3 |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Shablya, Y. Combinatorial Generation Algorithms for Some Lattice Paths Using the Method Based on AND/OR Trees. *Algorithms* **2023**, *16*, 266.
https://doi.org/10.3390/a16060266

**AMA Style**

Shablya Y. Combinatorial Generation Algorithms for Some Lattice Paths Using the Method Based on AND/OR Trees. *Algorithms*. 2023; 16(6):266.
https://doi.org/10.3390/a16060266

**Chicago/Turabian Style**

Shablya, Yuriy. 2023. "Combinatorial Generation Algorithms for Some Lattice Paths Using the Method Based on AND/OR Trees" *Algorithms* 16, no. 6: 266.
https://doi.org/10.3390/a16060266