Trees - liz-kavalski-401-advanced-javascript/seattle-javascript-401n13 GitHub Wiki

  • There are different ways to tranerval a tree. One is Depth First and Breadth First. The Depth First has three parts.Preorder which is the Root, Left, Right;Inorder the Left, Root, Right; or Postorder Left, Right, Root.
  • The root it the the current node in a linked list.
  • The breadth first traversal iterates through the tree by going through each level of the tree node by node.
  • Binary Trees are trees that only contain no more than 2 children. There is not a specific sorting order for a binary tree. Nodes can be added into a binary tree wherever space allows.
  • Adding a new node to a binary tree is to fill all “child” spots from the top down.
  • The Big O time of an insertion an searching in a Binary tree will always be O(n).
  • In a binary search tree, the tree is organized in a manner where all values that are smaller than the root are placed to the left, and all values that are larger than the root are placed to the right.
  • Compare the node you are searching for against each root of the tree. Dependent on the value being larger or smaller, will determine the direction on which you will traverse.