学习进度

学习进度

这周我学习了二叉树的基础操作和二叉树的性质,学习了二叉树的基础算法以下是我学习到的代码以及实际操作出来的一些产物:

建树

  • void Ctree(bitree *root)
  • {
  • char ch;
  • scanf("%c",&ch);
  • if(ch=='#')
  •   *root=NULL;
    
  • else
  • {
  •   *root=(bitnode *)malloc(sizeof(bitnode));
    
  •   (*root)->data=ch;
    
  •   Ctree(&((*root)->lchild));
    
  •   Ctree(&((*root)->rchild));
    
  • }
  • }

前序遍历

  • void Xtree(bitree root)
  • {
  • if(root==NULL)
  •   return;
    
  • else
  • {printf("%c",root->data);
  •   Xtree(root->lchild);
    
  •   Xtree(root->rchild);
    
  • }
  • }
posted @ 2020-05-10 19:00  牛炜明  阅读(136)  评论(0)    收藏  举报