Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- struct Node {
- int Data;
- Node* Left;
- Node* Right;
- };
- void DeleteTree(Node* node) {
- if (node == nullptr) return;
- DeleteTree(node->Left);
- DeleteTree(node->Right);
- delete node;
- }
- int main() {
- Node* root = new Node;
- root->Data = 2;
- root->Left = nullptr;
- root->Right = nullptr;
- root->Right = new Node;
- root->Right->Data = 5;
- root->Right->Left = nullptr;
- root->Right->Right = nullptr;
- DeleteTree(root);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement