http://blog.csdn.net/mxw976235955/article/details/39829973

http://www.tuicool.com/articles/zA7NJbj

/**
 *morris中序遍历二叉树
 */
void morris_inorder(BiTree T) {
  BNode *p, *temp;
  p = T;
  while(p) {
    if(p->left == NULL) {
      printf("%4c", p->ch);
      p = p->right;
    } else {
      temp = p->left;
      //找到左子树的最右子节点
      while(temp->right != NULL && temp->right != p) {
        temp = temp->right; 
      }
      if(temp->right == NULL) {
        temp->right = p;
        p = p->left;
      } else {
        printf("%4c", p->ch);
        temp->right = NULL;
        p = p->right;
      }
    }
  }
}

 

相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-11-17
相关资源
相似解决方案