
    Write a function to analyze user engagement patterns for an event category to determine if a specific engagement level dominates user interest. Given a sorted list of user activity scores and a target engagement level, determine if that engagement level represents the majority preference among users. The function should evaluate if the target engagement score appears more than half the time in the user activity dataset, which would indicate a strong collective interest level for that event category.
    

    
def binary_search(arr, low, high, x):
    if high >= low:
        mid = (low + high) // 2
        if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
            return mid
        elif x > arr[mid]:
            return binary_search(arr, mid + 1, high, x)
        else:
            return binary_search(arr, low, mid - 1, x)
    return -1

def is_majority(arr, n, x):
    """
    Write a function to analyze user engagement patterns for an event category to determine if a specific engagement level dominates user interest. Given a sorted list of user activity scores and a target engagement level, determine if that engagement level represents the majority preference among users. The function should evaluate if the target engagement score appears more than half the time in the user activity dataset, which would indicate a strong collective interest level for that event category.
    

    """
def binary_search(arr, low, high, x):
    if high >= low:
        mid = (low + high) // 2
        if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
            return mid
        elif x > arr[mid]:
            return binary_search(arr, mid + 1, high, x)
        else:
            return binary_search(arr, low, mid - 1, x)
    return -1

def is_majority(arr, n, x):
    """
    Write a function to analyze user engagement patterns for an event category to determine if a specific engagement level dominates user interest. Given a sorted list of user activity scores and a target engagement level, determine if that engagement level represents the majority preference among users. The function should evaluate if the target engagement score appears more than half the time in the user activity dataset, which would indicate a strong collective interest level for that event category.
    

    """
    i = binary_search(arr, 0, n - 1, x)
    if i == -1:
        return False
    if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
        return True
    else:
        return False