Skip to content

Instantly share code, notes, and snippets.

@atoye1
Last active December 14, 2021 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atoye1/d3deaa4d9a5291bd5be429d566d858f3 to your computer and use it in GitHub Desktop.
Save atoye1/d3deaa4d9a5291bd5be429d566d858f3 to your computer and use it in GitHub Desktop.
struct node{
struct node* left;
struct node* right;
int data;
}
struct node *tree_ptr;
void preorder(struct node* tree_ptr){
if (tree_ptr) {
printf("%d", tree_ptr->data);
preorder(tree_ptr->left);
preorder(tree_ptr->right);
}
}
// 중위 후위순회는 printf()의 위치를 변경함으로써 구현가능하다
// 단말노드의 left right 는 NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment