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.
Given an integer A. Compute and return the square root of A. If A is…
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…
A heap is a specialized tree-based data structure that satisfies the heap property. It is…
What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…
A Binary Search Tree (BST) is a type of binary tree that satisfies the following…