the process of an euler tour can easily be viewed recursively in between the "pre visitand "post visitof given position will be recursive tour of each of its subtrees looking at figure as an examplethere is contiguous portion of the entire tour that is itself an euler tour of the subtree of the node with element "/that tour contains two contiguous subtoursone traversing that position' left subtree and another traversing the right subtree the pseudo-code for an euler tour traversal of subtree rooted at position is shown in code fragment algorithm eulertour(tp)perform the "pre visitaction for position for each child in children(pdo eulertour(tc{recursively tour the subtree rooted at cperform the "post visitaction for position code fragment algorithm eulertour for performing an euler tour traversal of subtree rooted at position of tree the template method pattern to provide framework that is reusable and adaptablewe rely on an interesting object-oriented software design patternthe template method pattern the template method pattern describes generic computation mechanism that can be specialized for particular application by redefining certain steps to allow customizationthe primary algorithm calls auxiliary functions known as hooks at designated steps of the process in the context of an euler tour traversalwe define two separate hooksa previsit hook that is called before the subtrees are traversedand postvisit hook that is called after the completion of the subtree traversals our implementation will take the form of an eulertour class that manages the processand defines trivial definitions for the hooks that do nothing the traversal can be customized by defining subclass of eulertour and overriding one or both hooks to provide specialized behavior python implementation our implementation of an eulertour class is provided in code fragment the primary recursive process is defined in the nonpublic tour method tour instance is created by sending reference to specific tree to the constructorand then by calling the public execute methodwhich beings the tour and returns final result of the computation