DIR Return Create A Forum - Home
---------------------------------------------------------
Class H22
HTML https://classh22.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Summeries
*****************************************************
#Post#: 46--------------------------------------------------
binary trees
DIR By: SpiderGoat
Date: March 24, 2014, 11:19 am
---------------------------------------------------------
node - exist child.
leafs - a node with no children.
each may have right and left subtrees.
levels - starts from 0, increased with each's offsprings.
ways to scan:
pre-order - parent(root)>left>right
in-order - left>parent(root)>right
post-order- right>left>parent(root)
sorting:
if bigger>right, if lower>left. in that way, in-order will
produce bottom to to values.
O(n) = NlogN for building, logN for searching.
full - 2 children or leaf. no single child.
perfect - full, and all leaf in same level, and nosingle chilsd
complete - every level, except possibly the last, is completely
filled, and all nodes are as far left as possible
balanced - the depth of the left and right subtrees of every
node differ by 1 or less.
BST - binary search tree
every subtree is binary search tree.
single value - no duplicates.
left subtree smaller values than node.
right subtree bigger values than node.
find(num, node* tree)
if (tree == null) return null;
if (x < tree->element)
else if (x > tree->element)
else return tree;
*****************************************************
Page 1 of 1