http://www.geeksforgeeks.org/inorder-tree-traversal-without-recursion-and-without-stack/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> #include <string> #include <fstrea…
http://www.geeksforgeeks.org/inorder-tree-traversal-without-recursion/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> using namespace std; struct node { int data; struct node *lef…
http://www.geeksforgeeks.org/iterative-postorder-traversal-using-stack/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> #include <string> #include <fstream> #include &l…
http://www.geeksforgeeks.org/morris-traversal-for-preorder/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> #include <string> #include <fstream> #include <map> us…
http://www.geeksforgeeks.org/boundary-traversal-of-binary-tree/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> #include <string> #include <fstream> #include <map>…
http://www.geeksforgeeks.org/populate-inorder-successor-for-all-nodes/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> #include <string> #include <fstream> using namesp…
http://www.geeksforgeeks.org/construct-tree-from-given-inorder-and-preorder-traversal/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> #include <string> #include <fstream&…
http://www.geeksforgeeks.org/level-order-traversal-in-spiral-form/ #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <stack> using namespace std; struct node { int data; struct node *left, *…
struct node { int val; node *left; node *right; node *parent; node() : val(), left(NULL), right(NULL) { } node(int v) : val(v), left(NULL), right(NULL) { } }; node* insert(int n, node *root) { if (root == NULL) { root = new node(n); return root; } if…
给定一个二叉树,以集合方式返回其中序/先序方式遍历的所有元素. 有两种方法,一种是经典的中序/先序方式的经典递归方式,另一种可以结合栈来实现非递归 Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. OJ's Binary Tree Serialization: The s…