Model View Controller And Trees

Bioinfomatics Lecture

  • Friday, April 13, 2012, 4:00PM at NRC 106.

Apparently, we should have had this lecture BEFORE shapes1 was due...oh well.


  • The model is the data we're going to use
    • in Shapes1, it's the ArrayList of our shapes.
  • The View is the display of the model
    • in Shapes1, the View uses the components to help the shapes draw themselves.
  • The Controller controls either the view or the model
    • in Shapes1, it's the code managing mouse interaction & buttons. This was one of the very first important "design patterns" (way of structuring a program)

Formal Seperation

  • It's nice to keep the Model, View, and Controller kind of seperate.


General Trees

  • an empty tree
  • a root node

Binary Tree

  • an empty binary tree
  • or a root node
    • root may have left or right children that are also binary trees.

Example Binary Tree Use

(a-b) * c * | /\ - c | /\ a b

Height of a Tree

  • Node Level: length of path from root to the node
  • Height: Max level of all nodes of a tree. A tree-tree is preferred to a line-tree (that might be better off as a linked list)

Full Tree

A Binary tree is full if it is: * empty * A single root node * Left and right subtrees.....blarg.

Other Characterizations

Complete Binary Tree: * almost full, except for bottom leve, and leaves at bottom level are packed to the left. * This can be stored as an array!!! Balanced Binary Tree: * height of any node's right subtree differes from its left subtree height by no more than 1.


(there's a list in the PPT).