Comp202: Principles of Object-Oriented Programming II
Fall 2007 -- Design Patterns for Self-Balancing Trees    


  1. Introduction to run-time cost analysis: "Big-Oh" notation.   See below.
  2. Why do we need balanced trees?
    1. Trees offer much faster access than lists, but only if the tree so long as all the branches are nearly the same length, i.e. "balanced".
    2. A balanced tree gives O(log n) behavior, while lists give O(n) behavior.  
    3. Worst case scenario for an unbalanced tree is O(n) behavior.
  3. Demo code
    1. Pre-Java 5.0 JRE/SDK: 
      1. binaries in a jar file   (To run: java -jar NTree.jar)
      2. source code, zipped
    2. Java 5.0-compatible JRE/SDK
      1. DrJava project
      2. Executable jar file  (To run: java -jar dp4sbt_jre50.jar)
    3. Using generics and lambda-based extended visitors
      1. Executable jar file
      2. Source code, includes both lambda-based and case-statement based generic code.
  4. PowerPoint Presentationn  
  5. OOPSLA 2002 materials
    1. Paper in PDF format
    2. Poster (>740KB PNG file!)

Accounting For The Resources Used By Computations:  "Big-Oh" notation






(written by Alan Cox)

Quick and Dirty Explanation:

Big-Oh tells us how a cost of running a program (algorithm) scales with respect to n for large values of n, e.g. linearly, quadraticly, logarithmically, etc.   The slower the cost rises with n, the better, so long as we are dealing with large values of n.

Examples:

 


Last Revised Thursday, 03-Jun-2010 09:52:34 CDT

©2007 Stephen Wong and Dung Nguyen