data_structures.binary_tree.diff_views_of_binary_tree ===================================================== .. py:module:: data_structures.binary_tree.diff_views_of_binary_tree .. autoapi-nested-parse:: Problem: Given root of a binary tree, return the: 1. binary-tree-right-side-view 2. binary-tree-left-side-view 3. binary-tree-top-side-view 4. binary-tree-bottom-side-view Classes ------- .. autoapisummary:: data_structures.binary_tree.diff_views_of_binary_tree.TreeNode Functions --------- .. autoapisummary:: data_structures.binary_tree.diff_views_of_binary_tree.binary_tree_bottom_side_view data_structures.binary_tree.diff_views_of_binary_tree.binary_tree_left_side_view data_structures.binary_tree.diff_views_of_binary_tree.binary_tree_right_side_view data_structures.binary_tree.diff_views_of_binary_tree.binary_tree_top_side_view data_structures.binary_tree.diff_views_of_binary_tree.make_tree Module Contents --------------- .. py:class:: TreeNode .. py:attribute:: left :type: TreeNode | None :value: None .. py:attribute:: right :type: TreeNode | None :value: None .. py:attribute:: val :type: int .. py:function:: binary_tree_bottom_side_view(root: TreeNode) -> list[int] Function returns the bottom side view of binary tree 3 / \ 9 20 / \ 15 7 ↑ ↑ ↑ ↑ 9 15 20 7 >>> binary_tree_bottom_side_view(make_tree()) [9, 15, 20, 7] >>> binary_tree_bottom_side_view(None) [] .. py:function:: binary_tree_left_side_view(root: TreeNode) -> list[int] Function returns the left side view of binary tree. 3 -> 3 / \ 9 -> 9 20 / \ 15 -> 15 7 >>> binary_tree_left_side_view(make_tree()) [3, 9, 15] >>> binary_tree_left_side_view(None) [] .. py:function:: binary_tree_right_side_view(root: TreeNode) -> list[int] Function returns the right side view of binary tree. 3 <- 3 / \ 9 20 <- 20 / \ 15 7 <- 7 >>> binary_tree_right_side_view(make_tree()) [3, 20, 7] >>> binary_tree_right_side_view(None) [] .. py:function:: binary_tree_top_side_view(root: TreeNode) -> list[int] Function returns the top side view of binary tree. 9 3 20 7 ⬇ ⬇ ⬇ ⬇ 3 / \ 9 20 / \ 15 7 >>> binary_tree_top_side_view(make_tree()) [9, 3, 20, 7] >>> binary_tree_top_side_view(None) [] .. py:function:: make_tree() -> TreeNode >>> make_tree().val 3