Binary Trees Info Flashcards
Memorize
What is a Generic method and what is it used for
a.) It is a method definiton having a special type parameter that may be used in place for types
Define what a tree is?
A tree is a set of Nodes
What is the distingushed Node in a tree if it is not empty
Root
What is the External node called in a tree?
Leaf
What is the internal node in a tree
A node with one or more children
What is a path in a tree
A path from node Vi to node Vk is a sequence of nodes such that vi+1 for 1<=i<=k
What is the length of a tree?
The length of the tree is the number of edges encountered so (k-1)
What is the depth of a tree
The depth of any node is the length of the path from the root to the node
What is an Ancestor and what is a descendant
If there is a path from V1 to V2 then V1 is ancestor of V2 and V2 is the descendant of V1
What is the height of the tree
The height of the tree is the height of its root
What does a tree node include
An element and nodes linked together
What is the Special case of K-ary Trees
it is a tree whose nodes have at mose two children pointers – binary trees
Define a Binary Tree
It is a rooted tree in which no node can have more than two children AND the children are distinguished as left and right
What is a General Binary Tree
It is a tree where each node has a most two nodes
What is a full binary Tree
A binary tree where every interior node has two children or is an external node
What is a perfect Binary tree
A full binary tree that every external node is at the same level
what is a complete binary tree
It is like the perfect binary tree, except the last level may not be full but is filled from left to right
Define a Binary Search Tree
It is a binary tree in which at every node v the values stored in the left subtree is less than the values stored in the right subtree which is greater
What function must a BST class implement
A compareTo because the elements in the BST nodes must be comparable . Therefore a comparable interface or class must be defined
How do we find whether an element exist in a BST
a.) Traverse for only the match
b.) Otherwise not found so return null
What is the Running time for BST
O(Log N)
How do we Insert in a BST
Traverse down a tree until there is no subtree Then create a new node
What is the three cases for Deleting a node in BST
a.) A node has no children
delete it do nothhing more
b.) A node has one child
skip the node so that the node points to the child
c. A node has two children
replace the nodes data with the smallest data in right subtree
recursively delete the node
What functions does the Doubly linked List have
add, remove, isEmpty and etc