# Ticket #14498: trac_14498-typos-dg.patch

File trac_14498-typos-dg.patch, 7.6 KB (added by darij, 6 years ago)

not a review but just a fix for a couple typos. Jean-Baptiste, can you please look this over and qfold into your patch?

• ## sage/combinat/abstract_tree.py

# HG changeset patch
# User darij grinberg <darijgrinberg@gmail.com>
# Date 1373882103 25200
# Node ID 1cf21a01ec051e16660f07a9bbfc57b9279edb77
# Parent  db1599987dd58b219f8b46c6d1470fc8a36aebe1
just some typos

diff --git a/sage/combinat/abstract_tree.py b/sage/combinat/abstract_tree.py
 a class AbstractTree(object): def pre_order_traversal_iter(self): """ The depth first pre-order traversal iterator The depth-first pre-order traversal iterator. This method iters each node following the depth first pre-order This method iters each node following the depth-first pre-order traversal algorithm (recursive implementation). For example on the following binary tree b:: For example, on the following binary tree b:: |   ___3____      | |  /        \     | class AbstractTree(object): |        / \      | |       4   6     | the depth first pre-order traversal algorithm explores b in the following order of nodes 3,1,2,7,5,4,6,8. the depth-first pre-order traversal algorithm explores b in the following order of nodes: 3,1,2,7,5,4,6,8. The algorithm is:: manipulate the root then explore each subtrees (by the algorithm) manipulate the root, then explore each subtree (by the algorithm). An other example:: Another example:: |     __1____ | |    /  /   / | class AbstractTree(object): def iterative_pre_order_traversal(self, action=lambda _: None): """ The depth first pre-order traversal algorithm (iterative implementation) The depth-first pre-order traversal algorithm (iterative implementation). INPUT: - action -- a specific function which takes a node in input and do something during the exploration. something during the exploration. (see :meth:pre_order_traversal_iter  class AbstractTree(object): def pre_order_traversal(self, action=lambda _: None): """ The depth first pre-order traversal algorithm (recursive The depth-first pre-order traversal algorithm (recursive implementation) INPUT: class AbstractTree(object): |        / \      | |       4   6     | the depth first pre-order traversal algorithm explores b in the the depth-first pre-order traversal algorithm explores b in the following order of nodes 3,1,2,7,5,4,6,8. The algorithm is:: manipulate the root with function action manipulate the root with function action, then explore each subtrees (by the algorithm) An other example:: Another example:: |     __1____ | |    /  /   / | class AbstractTree(object): def post_order_traversal_iter(self): """ The depth first post-order traversal iterator The depth-first post-order traversal iterator This method iters each node following the depth first post-order This method iters each node following the depth-first post-order traversal algorithm (recursive implementation). For example on the following binary tree b:: class AbstractTree(object): |        / \      | |       4   6     | the depth first post-order traversal algorithm explores b in the the depth-first post-order traversal algorithm explores b in the following order of nodes 2,1,4,6,5,8,7,3. The algorithm is:: class AbstractTree(object): def post_order_traversal(self, action=lambda node: None): """ The depth first post-order traversal algorithm (recursive The depth-first post-order traversal algorithm (recursive implementation) INPUT: class AbstractTree(object): def iterative_post_order_traversal(self, action=lambda node: None): """ The depth first post-order traversal algorithm (iterative The depth-first post-order traversal algorithm (iterative implementation) INPUT: class AbstractTree(object): def breadth_first_order_traversal(self, action=lambda node: None): """ The breadth first order traversal algorithm. The breadth-first order traversal algorithm. INPUT: - action -- a specific function which takes a node in input and do something during the exploration. something during the exploration. For example on the following binary tree b:: For example, on the following binary tree b:: |   ___3____      | |  /        \     | class AbstractTree(object): |        / \      | |       4   6     | the breadth first order traversal algorithm explores b in the following order of nodes 3,1,7,2,5,8,4,6. the breadth-first order traversal algorithm explores b in the following order of nodes: 3,1,7,2,5,8,4,6. The algorithm is::
• ## sage/combinat/binary_tree.py

diff --git a/sage/combinat/binary_tree.py b/sage/combinat/binary_tree.py
 a class BinaryTree(AbstractClonableTree, C def in_order_traversal_iter(self): """ The depth first infix-order traversal iterator. The depth-first infix-order traversal iterator. This method iters each node following the infix order traversal algorithm. class BinaryTree(AbstractClonableTree, C |         / \   / \      | |        d   e f   g     | the depth first infixe-order traversal algorithm explores T in the depth-first infixe-order traversal algorithm explores T in the following order of nodes a,1,b,2,c,3,d,4,e,5,f,6,g,7,h,8,i. The algorithm:: class BinaryTree(AbstractClonableTree, C node_action=lambda _: None, leaf_action=lambda _: None): r""" The depth first infix-order traversal algorithm. The depth-first infix-order traversal algorithm. (see :meth:in_order_traversal_iter  class BinaryTree(AbstractClonableTree, C .. MATH:: f_{q} (T) = \\frac{[\\mid T\\mid]_q !}{\\prod_{t\\in T} q^{right(t)}[\\mid t\\mid]_q} q^{right(t)}\\mid t\\mid]_q} where \\mid T\\mid is the node number of T, t\\in T the set of all subtree of T and right(t) the number of node of the right subtree of t. of all subtrees of T, and right(t) the number of nodes of the right subtree of t. There is 20 permutations which give this shape binary tree:: There are 20 permutations which give a binary tree of the following shape:: |     __o__   | |    /     \  |