Note that there are some explanatory texts on larger screens.

plurals
  1. PORed Black Tree <Black Height> (Redraft)
    text
    copied!<pre><code>/** The following function checks the red black tree black height * @param n the root node is inputed then a traversal is done to calculate the black-height * @return Return an error message / mesages informing the user whether or not the black height was maintained * @author Ferron Smith */ public static void getCount (SkaRedBlackTreeNode skaRedBlackTreeNode) { VizRedBlackTreeNode n = skaRedBlackTreeNode.getVizRep(); if (validRoot(n)) { static int lcount = leftCount(n); static int rcount = rightCount(n); if (rcount == lcount) { n.displayMsg("Black height maintained"); } else // n.displayWarning("rcount " + rcount + " lcount " + lcount); n.displayError("Red Black Tree is unbalanced"); } } /** The following function counts all the black node of the left side of the tree * @param n the left child is inputed and a traversal is done to count all the black nodes * */ public static int leftCount (VizRedBlackTreeNode n) { if (n == null) return 0; else if (n.getrbtColr() == Color.black) return 1 + leftCount(n.getLeft()); else leftCount(n.getLeft()); } /** The following function counts all the black node of the right side of the tree * @param n the right child is inputed and a traversal is done to count all the black nodes * */ public static int rightCount (VizRedBlackTreeNode n) { if (n == null) return 0; else if (n.getrbtColr() == Color.black) { return 1 + rightCount (n.getRight()); else rightCount(n.getRight()); } } </code></pre> <p></p> <p>This is redraft, do you think this one will work, i've tested it on certain conditions and as not failed me yet</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload