旋转对中序遍历没有影响,直接中序输出即可。

  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4. int n;
  5. struct Shu
  6. {
  7. int left,rigth;
  8. }shu[1000005];
  9. int zhong(int id)
  10. {
  11. if(id>=0)
  12. {
  13. zhong(shu[id].left);
  14. cout<<id<<endl;
  15. zhong(shu[id].rigth);
  16. }
  17. }
  18. int main(int argc, char *argv[])
  19. {
  20. int t,i,j,x,y,z,m;
  21. cin>>t;
  22. while(t--)
  23. {
  24. cin>>n;
  25. for(i=0;i<n;i++)
  26. {
  27. cin>>x>>y>>z;
  28. shu[x].left=y;
  29. shu[x].rigth=z;
  30. }
  31. cin>>m;
  32. for(i=0;i<m;i++) cin>>x>>y;
  33. zhong(0);
  34. }
  35. return 0;
  36. }

nyist 202 红黑树(二叉树中序遍历)的更多相关文章

  1. nyoj202_红黑树_中序遍历

    红黑树 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 什么是红黑树呢?顾名思义,跟枣树类似,红黑树是一种叶子是黑色果子是红色的树... 当然,这个是我说的... & ...

  2. 二叉树中序遍历 (C语言实现)

    在计算机科学中,树是一种重要的非线性数据结构,直观地看,它是数据元素(在树中称为结点)按分支关系组织起来的结构.二叉树是每个节点最多有两个子树的有序树.通常子树被称作“左子树”(left subtre ...

  3. 94 Binary Tree Inorder Traversal(二叉树中序遍历Medium)

    题目意思:二叉树中序遍历,结果存在vector<int>中 解题思路:迭代 迭代实现: /** * Definition for a binary tree node. * struct ...

  4. [leetcode]94. Binary Tree Inorder Traversal二叉树中序遍历

    Given a binary tree, return the inorder traversal of its nodes' values. Example: Input: [1,null,2,3] ...

  5. 10.26最后的模拟DAY2 改造二叉树[中序遍历+严格递增的最长不下降子序列]

    改造二叉树 [题目描述] 小Y在学树论时看到了有关二叉树的介绍:在计算机科学中,二叉树是每个结点最多有两个子结点的有序树.通常子结点被称作“左孩子”和“右孩子”.二叉树被用作二叉搜索树和二叉堆.随后他 ...

  6. lintcode.67 二叉树中序遍历

    二叉树的中序遍历    描述 笔记 数据 评测 给出一棵二叉树,返回其中序遍历 您在真实的面试中是否遇到过这个题? Yes 样例 给出二叉树 {1,#,2,3}, 1 \ 2 / 3 返回 [1,3, ...

  7. LeetCode:94_Binary Tree Inorder Traversal | 二叉树中序遍历 | Medium

    题目:Binary Tree Inorder Traversal 二叉树的中序遍历,和前序.中序一样的处理方式,代码见下: struct TreeNode { int val; TreeNode* l ...

  8. [Leetcode] Binary tree inorder traversal二叉树中序遍历

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...

  9. leetCode 94.Binary Tree Inorder Traversal(二叉树中序遍历) 解题思路和方法

    Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tr ...

随机推荐

  1. python模块—urllib

    1. 网页操作 urllib.urlopen(url[,data[,proxies]]) 打开一个url,返回一个文件对象,然后可以进行类似文件对象操作 url:远程数据的路径,即网址 data:表示 ...

  2. OpenCV学习 7:图像形态学:腐蚀、膨胀

    原创文章,欢迎转载,转载请注明出处 首先什么是图像形态学?额,这个抄下百度到的答案.基本思想:    用具有一定形态的结构元素去度量和提取图像中的对应形状已达到对图像分析和识别的目的,形态学图像处理表 ...

  3. Sencha Touch对DOM的访问及控制

    HTML代码: <!doctype html> <html> <head> <meta charset="utf-8"> <t ...

  4. 这才是正确删除 office 的方式

    https://support.office.com/zh-cn/article/%E9%80%9A%E8%BF%87%E5%9C%A8%E9%87%8D%E6%96%B0%E5%AE%89%E8%A ...

  5. rsyslog masg和rawmsg的区别

    msg the MSG part of the message (aka "the message" ;)) message 的MSG 部分 rawmsg the message ...

  6. CentOS 安装Node.js

    先安装gcc-c++编译环境和openssl yum install gcc-c++ openssl-devel 然后 下载包并解压 cd /usr/local/src wget http://nod ...

  7. 关于matlab鼠标响应

    今天看了一下Matlab中响应鼠标的事件,整理如下, (1)函数WindowButtonMotionFcn,当鼠标在窗口上运动的时候就会相应此函数,于是在此函数中可以设置运动时想要的代码,如:改变鼠标 ...

  8. Hibernate中为什么要重写equals方法和hashcode方法

    1.*为什么要重写equals方法,首先我们来看一下equals源码: public boolean equals(Object anObject) { if (this == anObject) { ...

  9. Oracle查询表结构的常用语句

    1. 查询表结构基本信息 select * from user_tables t,user_tab_comments c where c.table_name = t.table_name and t ...

  10. ​c++ 调用DLL函数,出现错误

    ​c++ 调用DLL函数,出现错误 Run-Time Check Failure #0 - The value of ESP was not properly saved across a funct ...