Created
June 19, 2014 11:25
-
-
Save duyet/fcf53894a3558a7f8d1a to your computer and use it in GitHub Desktop.
Xuất những nút có chiều cao nhánh trái bằng chiều cao nhánh phải
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
| int max(int a, int b) { | |
| return (a > b) ? a : b; | |
| } | |
| int getHeight(TREE T) { | |
| if (T == NULL) return 0; | |
| return 1 + max(getHeight(T->left), getHeight(T->right)); | |
| } | |
| void print(TREE T) { | |
| if (T == NULL) return; | |
| print(T->left); | |
| if (getHeight(T->left) > 0 && getHeight(T->left) == getHeight(T->right)) { | |
| cout << T->value << " "; | |
| } | |
| print(T->right); | |
| } | |
| // Cấu trúc của node tự sửa lại cho khớp nha |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment