In binary trees, the views and types refer to different perspectives and classifications of the tree structure.
1
/ \
2 3
/ \ / \
4 5 6 7
/ \ \ /
8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
8
4
2 9 10
1 5 6 11
3 7
1 2 4 8
1 3 7 11
8 4 2 1 3 7 11
8 9 10 5 6 11 7
View Type | Time Complexity | Space Complexity |
---|---|---|
Horizontal View | O(n) | O(n) |
Vertical View | O(n log n) | O(n) |
Left View | O(n) | O(n) |
Right View | O(n) | O(n) |
Top View | O(n log n) | O(n) |
Bottom View | O(n) | O(n) |
1
/ \
2 3
/ \
4 5
1
/ \
2 3
/ \ /
4 5 6
1
/ \
2 3
/ \ / \
4 5 6 7
1
/ \
2 3
/ \
4 5
4
/ \
2 5
/ \ \
1 3 6
1
/
2
/
3
/
4
OR
1
\
2
\
3
\
4
Binary Tree Type | Time Complexity | Space Complexity |
---|---|---|
Full Binary Tree | O(n) | O(n) |
Complete Binary Tree | O(n) | O(n) |
Perfect Binary Tree | O(log n) | O(log n) |
Balanced Binary Tree | O(log n) | O(log n) |
Binary Search Tree (BST) | Average Case: O(log n) | O(n) |
Note: also read about Binary Trees: Structure & Tree travels
If you like my post please follow me to read my latest post on programming and technology.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
A builder plans to construct N houses in a row, where each house can be…
Find the length of the longest absolute path to a file within the abstracted file…
You manage an e-commerce website and need to keep track of the last N order…
You are given a stream of elements that is too large to fit into memory.…
The formula for the area of a circle is given by πr². Use the Monte…
Given an integer k and a string s, write a function to determine the length…