AP Comp Sci AB - FRQ

<p>Did anyone who took this successfully write the successor method (for the TreeNodes)?</p>

<p>I think I realize how to <em>now</em>, but I totally blanked during the test…</p>

<p>…the rest of them, I did fine on, I think. My preparation project for the MBCS was almost exactly Salmon, but writing the distance to home method myself.</p>

<p>for the succesors fr you just had to keep in mind 3 terminating cases.
given succesors(TreeNode t)

  1. If t is null or if the maximum valued node is located in t subtree.
  2. If t’s right points to null, and t is its parent’s right child then return the root.
  3. If t’s right points to null, and t is its parent’s left child return the minnode(t.getParent().getRight()) </p>

<p>otherwise just return the minnode(t.getRight())</p>