Trees + Tree Traversal Flashcards
1
Q
What is a tree?
A
- Symbol = T
- Undirected graph
- No Cycles but connected
- Used to represent or break down a range of problems or concepts
2
Q
How can you determine a tree structure?
A
- Each pair of verticies (u and v), one path from U to V
- That does not repeat any edges of vertices
- Additional edges between any vertices will produce a cycle
- Removing any edge produces a disconnected graph
3
Q
What are rooted trees?
A
- Common type of tree
- One vertex (point) is specified as a root
- Root usually at top of tree
- Therefore a tree with n vertices will have n-1 edges
4
Q
Give the structure of a tree
A
5
Q
What are binary trees?
A
- Rooted Tree
- In which every parent has at most two children
- Child can be left or right
- Every parent has at most one left and right child
-
FULL BINARY TREE each parent has two children
- Total Vertices = 2n + 1 (n is internal vertices)
-
Full m-ary tree - each parent has m children
- Total Vertices = mn + 1 (n is internal vertices)
6
Q
What are the calculations for a FULL binary tree
A
7
Q
What are the calculations for a m-ary tree
A
Total Vertices = mn + 1 (n is internal vertices)
8
Q
What is the importance of Binary Trees
A
- Used to represent a mathematical or logical equation
- Internal vertices are arithmetic operators
- Leaves are variables
- Can calculate using left to right
9
Q
What is preorder traversal
A
10
Q
What is inorder traversal?
A
11
Q
What is Postorder Traversal
A