Algorithms and OOD (CSC 207 2014S) : EBoards

CSC207.01 2014S, Class 54: Patterns of Design


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit

Questions (Exam and Otherwise)

Is there a way to compare two trees?

I have not written a comparator for trees. You could write one. It will probably look something like the following.

  public static boolean equals(BSTNode one, BSTNode two)
  {
    // Base case one: Both are the same node.  Obviously the same tree.
    // Also covers the both are null case.
    if (one == two)
      return true;

    // Base case two: One, but not the other is null.  Different trees.
    else if ((one == null) || (two == null))
      return false;

    // Recursive case: Both are nodes
    else return (one.key.equals(two.key)) &&
        (one.value.equals(two.value)) &&
        (equals(one.smaller, two.smaller)) &&
        (equals(one.larger, two.larger));
  } // equals(BSTNode, BSTNode)

Should we copy values or move nodes in rearranging trees?

Move nodes. It ends up working better in the long run, at least if I trust my experience and intuition.

Algorithm design

When given an algorithm design problem, how do you get started?

How Sam tends to approach algorithm design.

Much later

ADT design

Sam's basic questions on ADT design:

Data-structure design

When given a data-structure design problem, how do you get started?

What are Sam's basic questions on data structure design?

Object design

"Design Patterns"

Ways of thinking about common problems.

A language for expressiong common solutions.

I expect you to know (and have seen)

Code design

Copyright (c) 2013-14 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.