def longest_oscillation(L):
    """
    Function that finds the longest oscillation

    @param L                The list we wish to get the longest oscillation from
    @return long_osc        The length of the longest oscillation
    @return osc_index_list  List of the longest oscillation
    @complexity             For an input 'L' of size n, this function has O(n) time complexity as the list is only
                            looped over once, and O(n) auxiliary space complexity as two lists of size n are made in
                            the function (one for the indices, the other for the associated index values)
    """
    osc_list = []
    osc_index_list = []
    if L == []:
        return (0, [])
    for i in range(len(L)):
        if osc_list == []:
            osc_list = [L[i]]
            osc_index_list = [i]
        elif osc_list[-1] == L[i]:
            continue
        elif len(osc_list) == 1:
            osc_list.append(L[i])
            osc_index_list.append(i)
        elif (L[i] - osc_list[-1]) * (osc_list[-1] - osc_list[-2]) < 0:
            osc_list.append(L[i])
            osc_index_list.append(i)
        else:
            osc_list[-1] = L[i]
            osc_index_list[-1] = i
    long_osc = len(osc_index_list)
    return (long_osc, osc_index_list)