Created
January 8, 2018 20:22
-
-
Save denysvitali/20854e9bf5bb67fe195244aeee0e8e9e to your computer and use it in GitHub Desktop.
fml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void create_subtree_from_node(HuffmanTree *ht, Node *node, Node** result, int* pos){ | |
| if(pos[0] * HA_DIM_X + pos[1] >= HA_DIM_X * HA_DIM_Y){ | |
| return; | |
| } | |
| if(node != NULL) { | |
| if(DEBUG) { | |
| //printf("[create_subtree_from_node] pos: [%d][%d]\n", pos[0], pos[1]); | |
| } | |
| result[pos[0] * HA_DIM_X + pos[1]] = node; | |
| //ht->tree[node->node_number] = NULL; | |
| int left[2] = {pos[0]+1, pos[1]*2}; | |
| Node* n_left = node->left; | |
| int right[2] = {pos[0]+1, pos[1]*2 + 1}; | |
| Node* n_right = node->right; | |
| if(DEBUG && DEBUG_SWAP_SHOW_ARRAYS) { | |
| printf("Pos: [%d][%d]\n", pos[0], pos[1]); | |
| char* string; | |
| string = getElement(node); | |
| printf("Node itself: %s\n", string); | |
| printf("LEFT: \n"); | |
| printElement(n_left); | |
| printf("\nRIGHT: \n"); | |
| printElement(n_right); | |
| printf("\n"); | |
| } | |
| create_subtree_from_node(ht, n_left, result, left); | |
| create_subtree_from_node(ht, n_right, result, right); | |
| } else { | |
| //warn("[create_subtree_from_node] Node is null!"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment