Algorithm 2 Fuzzy Quicksort

Input: a sequence of nn intervals AA , where A[i].aA[i].a and A[i].bA[i].b denotes the lower and upper bound of the interval

Output: a sorted sequence of input intervals

1:FuzzyQuicksort(A,1,nA, 1, n)

2:

3:procedure FuzzyQuicksort(A,p,rA, p, r)

4:if p<rp < r then

5:(q,t)=(q, t) = FuzzyPartition(A,p,rA, p, r)

6:FuzzyQuicksort(A,p,q1A, p, q-1)

7:FuzzyQuicksort(A,t+1,rA, t+1, r)

8:end if

9:end procedure

10:

11:procedure FuzzyPartition(A,p,rA, p, r)

12:exchange A[p]A[p] with A[RANDOM(p,r)]A[RANDOM(p, r)]

13:x=A[p]x = A[p]

14:q=pq = p

15:t=pt = p

16:for i=p+1i = p + 1 to rr do

17:if A[i].b<x.aA[i].b < x.a then // interval less than condition

18:exchange A[q]A[q] with A[i]A[i]

19:q=q+1q = q + 1

20:exchange A[t+1]A[t+1] with A[i]A[i]

21:t=t+1t = t + 1

22:else if A[i].bx.aA[i].b \ge x.a and A[i].ax.bA[i].a \le x.b then // interval equal condition

23:exchange A[t+1]A[t+1] with A[i]A[i]

24:t=t+1t = t + 1

25:end if

26:end for

27:return (q,t)(q, t)

28:end procedure