Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct data {
- int average;
- } Data;
- typedef struct node {
- Dani dani;
- struct node* pLeft;
- struct node* pRight;
- } Node;
- Node* pRoot;
- void vydalennjaLystkiv(Node* pNode, Node* pParent, int which) {
- if(!pNode) {
- return;
- }
- int flag = 0;
- if(!pNode->left && !pNode->right) {
- flag = 1;
- if(which == 1) {
- pParent->pLeft = NULL;
- }
- else {
- pParent->pRight = NULL;
- }
- free(pNode);
- }
- if(!flag) {
- vydalennjaVuzliv(pNode->pLeft, pNode, 1);
- vydalennjaVuzliv(pNode->pRight, pNode, 2);
- }
- }
- void kstVuzliv(Node* pNode, int LIM, Node** ppNodes, int* index) {
- if(!pNode) {
- return;
- }
- if(pNode->dani.average > LIM) {
- ppNodes[*index] = pNode;
- (*index)++;
- }
- kstVuzliv(pNode->pLeft, LIM, kstVuzliv, index);
- kstVuzliv(pNode->pRight, LIM, kstVuzliv, index);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement