listing traversing circular linked list def traverselistref )curnode listref done listref is none while not done curnode curnode next print curnode data done curnode is listref of the loop is handled by the boolean variable donewhich is initialized based on the status of listref if the list is emptydone will be set to false and the loop never executes when the list contains at least one nodedone will be initialized to true and the loop is executed in the linear versions of the linked listthe first step in the body of the loop was to visit the current node ( print the contents of the node data fieldand then advance the traversal reference to the next node in this versionwe must first advance curnodeas illustrated in figure ( )and then perform the visit operation remembercurnode is initialized to reference the last node in the list in order to begin the traversal with the first nodethe temporary reference must be advanced to the first node in the list " " " " " "tlistref curnode " " (acurnode listref " " " " " " " (bfigure traversing circular linked list(ainitial assignment of the temporary reference and (badvancement of the temporary reference to the first node in the list finallydone is updated by examining curnode to determine if it has again reached the last node in the listas referenced by the listref reference curnode was initialized to be an alias of listrefbut it was advanced at the beginning of the loop thuswhen curnode again reaches the end of the listwe know every node has been visited and the loop can terminate