Binary Tree Traversals, Binary/Expression Trees, Binary Search Tree, Balanced Tree

5.0(1)
studied byStudied by 17 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/28

flashcard set

Earn XP

Description and Tags

Week 10, 11, 12

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

29 Terms

1
New cards

Traversal

Any process for visiting all of the nodes in some order

2
New cards

Recursive Solution and Iterative Solution

Two ways of implementing traversal

3
New cards

PreOrder Traversal

Visit each node before its children. Node > Left > Right

4
New cards

InOrder Traversal

Each node is processed between subtrees. Left > Node > Right

5
New cards

PostOrder Traversal

Each node is processed after subtrees traversal. Left > Right > Node

6
New cards

Level Order Traversal

Tree is traversed by each level. Similar to Breadth First Search

7
New cards

Spiral/Zigzag Level Order Traversal

Tree is traversed in spiral shape

8
New cards

Reverse Level Order Traversal

Visit last level first, then second last and eventually first level

9
New cards

Left Edge Nodes > Leaf Nodes > Right Edge Node (Bottom to Top)

Traverse boundary of binary tree.

10
New cards

Binary Expression Trees

A specific kind of binary tree used to represent expressions

11
New cards

Operands

Leaves Nodes (leaf node of the tree)

12
New cards

Operators

In Binary Expression Tree, it is also known as Internal Nodes

13
New cards

Infix

Binary Expression Tree: Left Child > Root Node > Right Child

14
New cards

Prefix

Binary Expression Tree: Root Node > Left Child > Right Child

15
New cards

Postfix

Binary Expression Tree: Left Child > Right Child > Root Node

16
New cards

Binary Search Tree

A node-based binary tree data structure

17
New cards

Print nodes at given level

BST Operations :: prints all the nodes at a particular level

18
New cards

Print all leaf nodes

BST Operations :: A node is a leaf node if both left and right child nodes of it are NULL

19
New cards

Right view of BST

BST Operations :: Set of nodes visible when tree is visited from right side

20
New cards

Left view of BST

BST Operations :: Set of nodes visible when tree is visited from left side

21
New cards

Height of BST

BST Operations :: Recursively calculated using the height of left and right subtrees of the node and assigns height to the node as max of the heights of two children plus 1

22
New cards

Delete node of BST

BST Operations :: Used to delete a node with specific key from the BST and return the new BST

23
New cards

Smallest Node of the BST

BST Operations :: Used to return the node with the smallest value in the tree

24
New cards

Total number of nodes in BST

BST Operations :: Returns the total count of nodes in the BST

25
New cards

Delete a BST

BST Operations :: Used to completely delete the BST and deallocate the memory

26
New cards

Balanced Tree

Follows the condition: The absolute difference of heights of left and right subtrees at any node is less than 1

27
New cards

Height Balanced Tree

Binary tree that is balanced based on the height of the subtrees.

Self-Balancing BST ; At every node, the absolute value if the difference in heights of the left and right subtrees is no larger than one

28
New cards

Weight Balanced BST

Binary tree that is balanced based on the weight on the edges of the tree.

For each node the number of nodes in the left subtree is at least half and at most twice the number of nodes in the right subtree

29
New cards

Left Edge Nodes, Leaf Nodes, Right Edge Nodes

Boundary traversals three essential parts