| 1234567891011121314151617181920212223242526272829 |
- #include <stdlib.h>
- #include "tree.h"
- /* DO NOT MODIFY THIS FUNCTION!!! */
- void Huff_postOrderPrint(HuffNode *tree)
- {
- // Base case: empty subtree
- if (tree == NULL) {
- return;
- }
- // Recursive case: post-order traversal
- // Visit left
- printf("Left\n");
- Huff_postOrderPrint(tree->left);
- printf("Back\n");
- // Visit right
- printf("Right\n");
- Huff_postOrderPrint(tree->right);
- printf("Back\n");
- // Visit node itself (only if leaf)
- if (tree->left == NULL && tree->right == NULL) {
- printf("Leaf: %c\n", tree->value);
- }
-
- }
|