Week 5 Flashcards
Tree
A set of interconnected nodes with no closed circuits or loops
Subtree
A tree rooted an internal node of the tree
Leaf(terminal node)
Any tree rooted an internal node of the tree
Root node
The first node of the tree
Branch
A link between two nodes within the tree
Degree of a node
Number of subtrees of that node
Level of a node
Number of branches on the path from the root to the node
Height / Depth of a tree
Number of nodes on the longest path from the root node to a leaf node
What is a Binary tree ?
Is a special case of a tree where every node is of degree two or less
A Binary Search Tree is a special case of a Binary tree where :
*The keys in the left subtree of the root precede the key in the root
*The key in the root node precedes the keys
*The left and right subtrees of the root are also Binary Search Trees
The first item is based on the normal binary search algorithm where:
*The first item to be tested will be stored in the root node
*If the required item is stored in this node then our search is complete
*If the required item comes before the data item stored in the root node then we will search the left subtree
*If the required item comes after the data item stored in the root node then we will search the right subtree
*The search will then process until either we locate the required data item or we reach a leaf node when we know that the required item is not stored in the BST
Cases to be considered before deleting a node from a BST
*The node is a leaf node
*The node has one subtree
*The node has two subtrees
Types of approaches to the traversal of a binary tree:
*Depth First Traversal (DFT)
*Breadth First Traversal (BFT)
Depth First Traversal (DFT)
The traversal proceeds along a path from the root through one child to the MOST distant descendant of that first child before processing the second child. To
implement this traversal a STACK is used.
Breadth First Traversal (BFT)
The traversal proceeds HORIZONTALLY from the root to all of its children then to its
children’s children and so on until all nodes have been processed. To implement this
traversal a QUEUE is used.