void checkBlack(link h,int blackCount) // Checks that all paths downward from a node have the same // number of black nodes { if (h==z) if (blackCount==!(h->red)) return; else { printf("Black height problem!\n"); STprintTree(); exit(0); } if (h->red) { checkBlack(h->l,blackCount); checkBlack(h->r,blackCount); } else { checkBlack(h->l,blackCount-1); checkBlack(h->r,blackCount-1); } }
void verifyRBproperties() // Checks all required properties. // If a fatal problem is found, the tree is printed before exit(0) { int lpbHeight;//left probe black height if (head->red)//check to make sure root is black printf("Root is not black!\n"); if (z->red)//check to make sure sentinel is black printf("Sentinel is not black!\n"); lastInorder=(-99999999); //set the last node processed to not processed somewhat global variable checkInorder(head);// Checks that inorder yields keys in ascending order checkRed(head,0);//checks for red parent and red child exisitence lpbHeight=leftPathBlackHeight(head);//from the head checks the black height traversing to the minimum key value checkBlack(head,lpbHeight);//checks the black height of a given node with an Int this being the height of the min key val }
void printPerms(int* perm,int n,int k,int** intArray, int col,int row){ int i; if (n == row){ ///this is a check function for black and white ///this function will return 1 if a testcase passes all clues int cb = checkBlack(perm,n+1,intArray,col,row); // if(cb == 1){ counter++; } }//end of if else{ for(i=0;i<k;i++){ perm[n] = i; ///permutation function printPerms(perm,n+1,k,intArray,col,row); } } }//end of fillPerm