Close
Close

Time complexity of the Python Function

   Zuhaib.786

What is the time complexity of the below python function which takes A_new,B_new and C_new  lists of same size(n) as argument.Explain

def disjoint_mystrey(A_new,B_new,C_new):
    A,B,C=sorted(A_new),sorted(B_new),sorted(C_new)
    i,j,k=0,0,0
# i,j,k act as pointers of the first second and thiird set
    while i<len(A):
        if A[i]<B[j] and i<len(A):
            i+=1
        elif B[j]<A[i] and j<len(B):
            j+=1
        elif j==len(B) or i==len(A):
            return True
        elif A[i]==B[j]:
            while C[k]<A[i]:
                k+=1
            if C[k]==A[i]:
                return False
            else:
                i+=1
    return True


Answers

Ask Yours
Post Yours
Write your answer