data_structures.binary_tree.diff_views_of_binary_tree

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

TreeNode

Functions

binary_tree_bottom_side_view(→ list[int])

Function returns the bottom side view of binary tree

binary_tree_left_side_view(→ list[int])

Function returns the left side view of binary tree.

binary_tree_right_side_view(→ list[int])

Function returns the right side view of binary tree.

binary_tree_top_side_view(→ list[int])

Function returns the top side view of binary tree.

make_tree(→ TreeNode)

Module Contents

class data_structures.binary_tree.diff_views_of_binary_tree.TreeNode
left: TreeNode | None = None
right: TreeNode | None = None
val: int
data_structures.binary_tree.diff_views_of_binary_tree.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)
[]
data_structures.binary_tree.diff_views_of_binary_tree.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)
[]
data_structures.binary_tree.diff_views_of_binary_tree.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)
[]
data_structures.binary_tree.diff_views_of_binary_tree.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)
[]
data_structures.binary_tree.diff_views_of_binary_tree.make_tree() TreeNode
>>> make_tree().val
3