/*general tree adt *interface gentree public void clear()/clear the tree public gtnode root()/return the root /make the tree have new rootgive first child and sib public void newroot( valuegtnode firstgtnode sib)public void newleftchild( value)/add left child figure the general tree node and general tree classes access to the left and right child pointers unfortunatelybecause we do not know in advance how many children given node will have in the general treewe cannot give explicit functions to access each child an alternative must be found that works for any number of children one choice would be to provide function that takes as its parameter the index for the desired child that combined with function that returns the number of children for given node would support the ability to access any node or process all children of node unfortunatelythis view of access tends to bias the choice for node implementations in favor of an array-based approachbecause these functions favor random access to list of children in practicean implementation based on linked list is often preferred an alternative is to provide access to the first (or leftmostchild of nodeand to provide access to the next (or rightsibling of node figure shows class declarations for general trees and their nodes based on these two access functionsthe children of node can be traversed like list trying to find the next sibling of the rightmost sibling would return null general tree traversals in section three tree traversals were presented for binary treespreorderpostorderand inorder for general treespreorder and postorder traversals are defined with meanings similar to their binary tree counterparts preorder traversal of general tree first visits the root of the treethen performs preorder traversal of each subtree from left to right postorder traversal of general tree performs postorder traversal of the root' subtrees from left to rightthen visits the root inorder traversal does not have natural definition for the general treebecause there is no particular number of children for an internal node an arbitrary definition -such as visit the leftmost subtree in inorderthen the rootthen visit the remaining subtrees in inorder -can be invented howeverinorder traversals are generally not useful with general trees