If linked list is not None then set the next of last node
if ( head_ref != None ) : NEW_LINE INDENT while ( temp . next != head_ref ) : NEW_LINE INDENT temp = temp . next NEW_LINE DEDENT temp . next = ptr1 NEW_LINE DEDENT else : NEW_LINE