------
## 最终结论
```python
def maxTurbulenceSize(A):
    if not A:
        return 0
    
    max_length = 1
    current_length = 1
    
    for i in range(1, len(A)):
        if A[i] > A[i - 1]:
            if i % 2 == 1:
                current_length += 1
            else:
                current_length = 2
        elif A[i] < A[i - 1]:
            if i % 2 == 0:
                current_length += 1
            else:
                current_length = 2
        else:
            current_length = 1
        
        max_length = max(max_length, current_length)
    
    return max_length

# Example usage:
print(maxTurbulenceSize([9,4,2,10,7,8,8,1,9])) # Output: 5
print(maxTurbulenceSize([4,8,12,16])) # Output: 2
print(maxTurbulenceSize([100])) # Output: 1
```