码迷,mamicode.com
首页 >  
搜索关键字:preorder traversal    ( 1851个结果
Leetcode: Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.与Construct Binary Tree from Inorder and Preorder Traversal问题非常类似,唯一区别在于这一次确...
分类:其他好文   时间:2014-09-16 12:09:50    阅读次数:212
Leetcode: Construct Binary Tree from Preorder and Inorder Transversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.难度:95,参考了网上的思路。...
分类:其他好文   时间:2014-09-16 12:09:00    阅读次数:174
二叉树的非递归遍历
先序遍历: void preOrder(Node *p) //非递归 { if(!p) return; stack s; Node *t; s.push(p); while(!s.empty()) { t=s.top(); printf("%d\n",t->data); s.pop(); if(t->ri...
分类:其他好文   时间:2014-09-15 19:36:09    阅读次数:152
Leetcode: Binary Tree Level Order Transversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For e...
分类:其他好文   时间:2014-09-15 14:13:38    阅读次数:153
Leetcode: Binary Tree Level Order Transversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,...
分类:其他好文   时间:2014-09-15 14:07:38    阅读次数:175
Leetcode: Binary Tree Inorder Transversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2]....
分类:其他好文   时间:2014-09-15 09:54:08    阅读次数:135
Leetcode Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal 结题报告 从前序遍历和中序遍历的结果重建一颗二叉树。 解题思路,随便写一个二叉树,然后写出前序和中序遍历的结果会发现特点。 二叉树的首节点必然是前序遍历的第一个节点,以这个节点在中序遍历的结果中作为划分,这个节点左侧的是左子树的节点,右侧是右子树节点。 例如,一个二叉...
分类:其他好文   时间:2014-09-14 20:48:47    阅读次数:176
理清递归、迭代、循环的概念
loop、iterate、traversal和recursion这几个词是计算机技术书中经常会出现的几个词汇。众所周知,这几个词分别翻译为:循环、迭代、遍历和递归。乍一看,这几个词好像都与重复(repeat)有关,但有的又好像不完全是重复的意思。那么这几个词到底各是什么含义,有什么区别和联系呢?下面...
分类:其他好文   时间:2014-09-13 21:22:05    阅读次数:538
Binary Tree Preorder Traversal
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:其他好文   时间:2014-09-13 20:06:25    阅读次数:173
打印二叉树
首先根据前序和中序构造一棵二叉树,然后利用中序遍历和广度优先将树按照形状打印出来。#include #include #include #define MAX 1000/*print the treefirst:using the preorder and inoder,create a treet...
分类:其他好文   时间:2014-09-11 22:07:52    阅读次数:233
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!