Skip to content

Conversation

@gillespiecd
Copy link
Contributor

@gillespiecd gillespiecd commented Jul 18, 2019

Background

I enjoy using binarytree, especially find printing useful in ipython.

I thought it would be fun to add a new property is_symmetric to properties. This comes up sometimes as an exercise with trees -- is it symmetric (a mirror of itself).

Also wanted to learn more about the doctest and coverage modules 👍

Updates

  1. Add new property and function to calculate if binary tree is symmetric

Steps to Reproduce

>>> from binarytree import Node >>> a = Node(5) >>> a.is_symmetric True >>> a.left = Node(6) >>> a.is_symmetric False >>> a.right = Node(6) >>> a.is_symmetric True >>> a.right.left = Node(7) >>> a.is_symmetric False >>> a.right.right = Node(8) >>> a.left.left = Node(8) >>> a.left.right = Node(7) >>> print(a) __5__ / \ 6 6 / \ / \ 8 7 7 8 >>> a.is_symmetric True 
@coveralls
Copy link

coveralls commented Jul 18, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 3523749 on gillespiecd:symmetric into 23cb6f1 on joowani:dev.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling c0a796d on gillespiecd:symmetric into 23cb6f1 on joowani:dev.

@joowani joowani merged commit 035fec9 into joowani:dev Jul 19, 2019
@joowani
Copy link
Owner

joowani commented Jul 19, 2019

Hi @gillespiecd,

Looks good! Thank you for your interest and contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants