From: Michelangelo Grigni (mic@mathcs.emory.edu)
Date: Mon Feb 06 2012 - 14:59:53 EST
JH writes: > I'm a little confused about the constructors that need to go in the > programs. What all does it need to initialize? You need to write a constructor for both of your classes, and the constructor should take a single int: WeightedQuickUnionUF(int N) PathCompQuickUnionUF(int N) The second is easier, because it needs to do exactly the same thing as the constructor in the parent class, QuickUnionUF. The "slick" way is to call the parent constructor, a one-liner: super(N); The first is a bit harder. You can still start with super(N); which takes care of the id array. But then you also need some code (from the book) to allocate and initialize the sz array. Note the sz array should be a new data member in this class (not in the parent). The textbook code avoids inheritance, you are refactoring to use inheritance ("refactor" is how programmers say "rewrite").
This archive was generated by hypermail 2.1.4 : Wed Apr 04 2012 - 17:34:17 EDT