Identical Linked Lists | A recursive Python3 function to check if two linked lists are identical or not ; If both lists are empty ; If both lists are not empty , then data of current nodes must match , and same should be recursively true for rest of the nodes . ; If we reach here , then one of the lists is empty and other is not
def areIdentical ( a , b ) : NEW_LINE INDENT if ( a == None and b == None ) : NEW_LINE INDENT return True NEW_LINE DEDENT if ( a != None and b != None ) : NEW_LINE INDENT return ( ( a . data == b . data ) and areIdentical ( a . next , b . next ) ) NEW_LINE DEDENT return False NEW_LINE DEDENT