Skip to the content.

Code 401 Class 15 Reading Notes

Tree

Common Terminology

Traversals: Depth First and Breadth First

Depth first traversal: Going through the depth (height) of the tree first.

a) left » root » right

b) left » right » root

c) root » left » right

ALGORITHM preOrder(root)

  OUTPUT <-- root.value

  if root.left is not NULL
      preOrder(root.left) ## 

  if root.right is not NULL
      preOrder(root.right)

Things I want to know more about

How to return/print the top or left side of the binary tree.

<—BACK