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 encode_word(string &s) { | |
encode_word_helper(s, 0); | |
} | |
void encode_word_helper(string &s, int i) { | |
if (i == s.size()) { | |
cout << reduce(s) << endl; | |
return; | |
} | |
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 mutate_tree_bfs(const shared_ptr<BinaryTree> &root) { | |
stack<shared_ptr<BinaryTree>> stack1; | |
stack<shared_ptr<BinaryTree>> stack2; | |
stack<shared_ptr<BinaryTree>> *st1 = &stack1; | |
stack<shared_ptr<BinaryTree>> &st2 = &stack2; | |
st1->push(root); | |
shared_ptr<BinaryTree> *temp = nullptr; | |
bool is_left_most = true; |
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 mutate_binary_tree(const shared_ptr<BinaryTree> &root) { | |
if (!root) { | |
return; | |
} | |
mute_dfs_post_order(root); | |
shared_ptr<BinaryTree> n = root; | |
while (n->left) { | |
auto current = n; | |
auto next = current->left; | |
next = get_right_most(next); |
NewerOlder