Trees Flashcards
(8 cards)
What is a Tree?
structure consisting of one node called the root and zero or one or more subtrees
edges flow from the root
Heap
complete binary tree which satisfies the heap ordering property
max-heap: every node is larger than its children
min-heap: every node is smaller than its children
insertion/deletion algorithm
deletion always happens at root
Balanced Binary Tree
for every node, the height of each subtree does not differ by more than one
Complete Binary Tree
every level of the tree is filled until the last level that is filled to the left with leaf nodes
Binary Search Tree
left subtree of a node contains only nodes with smaller values
right subtree of a node contains only nodes with larger values
the left and right subtree each must also be a binary search tree
Breadth First Traversal
algorithm for traversing or searching tree or graph data structures.
starts at the tree root (or some arbitrary node of a graph) and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level
Depth First Traversal
algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking
Types of Depth First Traversals
Preorder Traversal (root, left, right) Inorder Traversal (left, root, right) Postorder Traversal (left, right, root)