The most elegant way to print a Binary Tree
来源:互联网 发布:linux命令是否进行安装 编辑:程序博客网 时间:2024/05/16 15:52
class TreeNode {public: int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};void display(TreeNode* root, int col = 0) { if(root == 0) return; display(root->right, col + 1); for(int i = 0; i < col; ++i) std::cout<<"| "; cout<<"|"<<root->val<<std::endl; display(root->left, col + 1);}int main() { TreeNode *root = new TreeNode(0); root->left = new TreeNode(1); root->right = new TreeNode(2); root->left->left = new TreeNode(3); root->left->right = new TreeNode(4); root->right->left = new TreeNode(5); root->right->right = new TreeNode(6); root->right->right->right = new TreeNode(7); display(root); return 0;}
0 0
- The most elegant way to print a Binary Tree
- Print Boundry Nodes of a binary tree.
- print out the path from one node to another in binary tree
- [Google] print the outline of a complete binary tree in anti-clockwise direction
- A smart way to count the ONEs in an integer's binary form representation
- The best way to fix a bug
- Pretty print binary tree
- print binary tree boundary
- Print binary tree
- 655. Print Binary Tree
- 655. Print Binary Tree
- 655. Print Binary Tree
- Leetcode655. Print Binary Tree
- LeetCode Print Binary Tree
- 655. Print Binary Tree
- Print Binary Tree
- LeetCode_655. Print Binary Tree
- 655. Print Binary Tree
- 各种分布式文件系统简介
- ASP.NET面试经历分享
- servlet的运行
- printf、sprintf与fprintf 的用法区分
- Html转jsp后页面前后不一致原因
- The most elegant way to print a Binary Tree
- VMware Mac OS X 不支持二进制编译。若要运行 Mac OS X 主机上需要一个
- Delta3D 中STAGE之PropertyEditor
- 组合模式
- Probability Through Experiments
- DICOM VR (Value Representations)表
- Windows Phone App测试良好但提交后失败的可能性
- 潜意识心理学
- Oracle的锁表与解锁