int main(){ TreeNode *root=inputTree(); Solution s; cout<<s.maxDepth(root); system("pause"); return 0; }
void EFMGenerator::generateCombinations(int metaboliteIndex, int inputCount, int outputCount) { bptInput.init(); bptOutput.init(); bptNonpart.init(); //Identify input, output and non-participating pathways for the given metabolite int prevSize = pathways.size(); for (int i = prevSize - 1, in = 0, out = inputCount; i >= 0; i--) { if (pathways[i].isInput(metaboliteIndex)) { pathwaysPtr[in++] = &pathways[i]; bptInput.addPathway(&pathways[i]); } else if (pathways[i].isOutput(metaboliteIndex)) { pathwaysPtr[out++] = &pathways[i]; bptOutput.addPathway(&pathways[i]); } else { bptNonpart.addPathway(&pathways[i]); } } //Create reversible trees for inputs and outputs ReversibleTree inputTree(pathwaysPtr, 0, inputCount); ReversibleTree outputTree(pathwaysPtr, inputCount, inputCount + outputCount); //Generate combinations generateCombinations(inputTree.getRoot(), outputTree.getRoot()); //Update list of pathways in the network for (int i = pathways.size() - 1; i >= prevSize; i--) { pathways[i].updateMetaboliteCoefficients(metaboliteIndex); } for (int i = prevSize - 1; i >= 0; i--) { if (pathways[i].isInput(metaboliteIndex) || pathways[i].isOutput(metaboliteIndex)) { pathways.remove(i); } } clearBPTNodePool(); clearRevNodePool(); }
int main (int argc, const char * argv[]) { int height; printf("\n\tEnter height of the tree: "); scanf(" %d", &height); TREE_p_t tree = initTree(height); printf("\n\tEnter the tree (characters) '#' for null\n: "); inputTree(tree); char choice = '\0'; do { printf("\n\n\t1. Input tree (overwrite)\n\t2. Inorder transversal\n\t3. Preorder transversal\n\t4. Postorder transversal\n\tChoice: "); scanf(" %c", &choice); if (choice == '1') { printf("\n\tEnter height of the tree: "); scanf(" %d", &height); tree = initTree(height); inputTree(tree); } else if (choice == '2') { printf("\n\n\t Inorder: "); inorderTransversal(tree, 1); } else if (choice == '3') { printf("\n\n\t Preorder: "); preorderTransversal(tree, 1); } else if (choice == '4') { printf("\n\n\tPostorder: "); postorderTransversal(tree, 1); } } while (choice >= '1' && choice <= '4'); printf("\n\n"); }
int main(){ TreeNode *root=inputTree(); Solution s; s.preorderTraversal(root); return 0; }