Skip to main content
. 2021 Jun 11;23(6):737. doi: 10.3390/e23060737
Algorithm 3 Selecting a Similar Set Based on Vertical Position
Input: States s
Output: Similar set Svp of s
  1: Create 2 empty stack: stack1, stack2
  2: while s  do
  3:    a is the action that pops from the head of state s
  4:    if a=f then
  5:        Push a to stack1
  6:    else if a=b then
  7:        if stack then
  8:           Pop an element from stack1
  9:        end if
10:    else if a=e then
11:        Clear stack1
12:    else if a=sd then
13:        Push a to stack2 and clear stack1
14:    end if
15: end while
16: Measure the length of the stack1 and stack2 and mark them as l1 and l2 respectively
17: Svp=
18: S=Spa
19: while Sθ·Spa  do
20:    Select s from S
21:    Calculate l1 and l2 by executing Line 1 to Line 16 with s
22:    if l1=l1 and l2=l2 then
23:        Svp=Svp{s}
24:        S=S{s}
25:    else
26:        S=S{s}
27:    end if
28: end while
29: Return Svp