knakul853

Untitled

Jul 22nd, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. /*
  2. knakul853
  3. */
  4. void goleft(node* root){
  5.    
  6.     if(root == NULL) return;
  7.         goleft(root->left);
  8.     cout<<root->data<<" ";
  9. }
  10. void goright(node * root){
  11.    
  12.     if(root == NULL){
  13.        
  14.     return;
  15.     }
  16.     cout<<root->data<<" ";
  17.     goright(root->right);
  18. }
  19. void topView(node * root) {
  20.  node * p =root;
  21.     node * q =root;
  22.     if(root==NULL)return;
  23.     if(p->left != NULL){
  24.        
  25.         goleft(p->left);
  26.     }
  27.     cout<<root->data<<" ";
  28.     if(q->right != NULL)
  29.     goright(q->right);
  30.  
  31. }
Add Comment
Please, Sign In to add comment