Chapter 39 - Trees Flashcards
What does a rooted tree have?
» Has a root
» Branches
» Leaves
What are the differences between a tree in computer science and real life?
» In computer science has its root at the top and its leaves at the bottom
What are the typical uses for rooted trees?
» Manipulating hierarchial data
» Manipulated sorted lists of data
» Making information easy to search
What is a tree?
» A tree is a fundamental data structure
» Consists of nodes and pointers
What does each tree have?
» A root node
What are the leaf nodes?
» Nodes at the very bottom of the tree
» And a node which has no children
What are nodes connected with?
» Pointers also known as edges
What is a subtree?
» A set of nodes and edges from any single node down through all of its descendants is known as a subtree
What does each edge connect?
» 2 nodes
» Evert node except the root is connect by exactly one edge from another node
What is the root?
» Only root which has no incoming edges
What is the child ?
» The set of nodes that have incoming edges from the same node
What is a binary tree?
» Similar to a standard rooted tree
» In which eah node has a maximum of 2 children
What is a binary tree?
» Similar to a standard rooted tree
» In which eah node has a maximum of 2 children
How can binary trees be represented in memory?
» As dicitonaries
What are the values of the right pointer/ left pointer if there is no child node?
» Null
What are the applications of binary trees?
» Database applications where efficient searching is required
» Wireless networking and routing tables
What does each node in a binary tree contain?
» A left pointer
» A right pointer
» Data
What are the steps to add an item to a binary tree?
» Check if there is free memory for the node - if there isn’t output an error
» Create a new node and insert data into it