void printStructure(Node<ValueType> *root,
                    std::unordered_map<Node<ValueType>*, bool> &visitedNodes) {
    if (root == nullptr) {
        printf("NULL ");
    } else if (visitedNodes.find(root) == visitedNodes.end()) {
        visitedNodes[root] = true;
    
        printStructure(root->left, visitedNodes);
        printf("%d ", root->value);
        printStructure(root->right, visitedNodes);
    }
}
Exemple #2
0
int main(void) {

	populateArrayOfStructs();
	printStructure();

	return EXIT_SUCCESS;
}
void printAndDeleteStructure(Node<ValueType> *&root) {
    printStructure (root);
    
    printf("\n----------\n");
    
    deleteStructure(root);
}
Exemple #4
0
int main(int argc, const char * argv[]) {
    // insert code here...

    // populate the array
    populateArrayOfStructs();
    // print them out
    printStructure();
    
    
    return EXIT_SUCCESS;
}
Exemple #5
0
int main(void) {

	struct test test1;
	printf("size of test1: %d\n", sizeof(test1));

	//citizen is a variable of type person
	struct person citizen;
	citizen.age = 38;
	citizen.height = 5.9;
	strcpy(citizen.lastName,"Johnson");
	strcpy(citizen.firstName,"Sasha");
	strcpy(citizen.eyeColor,"Green");

	printStructure(citizen);  //Pass the entire structure to the function as one argument

	return EXIT_SUCCESS;
}
void printStructure(Node<ValueType> *root) {
    std::unordered_map<Node<ValueType>*, bool> visitedNodes;
    
    printStructure(root, visitedNodes);
}