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