码迷,mamicode.com
首页 >  
搜索关键字:treenode    ( 1958个结果
《剑指offer》第三十二题III:之字形打印二叉树
// 面试题32(三):之字形打印二叉树 // 题目:请实现一个函数按照之字形顺序打印二叉树,即第一行按照从左到右的顺 // 序打印,第二层按照从右到左的顺序打印,第三行再按照从左到右的顺序打印, // 其他行以此类推。 #include <cstdio> #include "BinaryTree. ...
分类:其他好文   时间:2020-03-31 01:37:58    阅读次数:69
树的遍历
2.3二叉树的遍历 树的表示 1 //树的表示 2 typedef struct TreeNode *BinTree; 3 struct TreeNode 4 { 5 int Data;//存值 6 BinTree Left;//左儿子结点 7 BinTree Right;//右儿子结点 8 }; ...
分类:其他好文   时间:2020-03-28 13:17:09    阅读次数:72
LeetCode-两棵二叉搜索树的所有元素
注:LeetCode--树专题。 题目链接(1305):https://leetcode-cn.com/problems/all-elements-in-two-binary-search-trees/ 题目描述: 给你 root1 和 root2 这两棵二叉搜索树。 请你返回一个列表,其中包含 两 ...
分类:其他好文   时间:2020-03-27 21:47:16    阅读次数:80
LeetCode 653. Two Sum IV - Input is a BST(在BST中寻找两个节点,使它们的和为一个给定值)
题意:在BST中寻找两个节点,使它们的和为一个给定值。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(in ...
分类:其他好文   时间:2020-03-26 01:22:25    阅读次数:70
剑指offer-平衡二叉树
题目描述 输入一棵二叉树,判断该二叉树是否是平衡二叉树。 public class Solution { public boolean IsBalanced_Solution(TreeNode root) { if(root==null) return true; int depthleft = T ...
分类:其他好文   时间:2020-03-25 21:01:32    阅读次数:62
设计模式——组合模式
//树节点import java.util.ArrayList;import java.util.List;public class TreeNode { private int id; private String name; private List child = new ArrayList(... ...
分类:其他好文   时间:2020-03-25 19:12:06    阅读次数:53
LeetCode 236. Lowest Common Ancestor of a Binary Tree(二叉树求两点LCA)
题意:二叉树求两点LCA。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), ...
分类:其他好文   时间:2020-03-24 23:20:14    阅读次数:73
105. 从前序与中序遍历序列构造二叉树
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), ...
分类:其他好文   时间:2020-03-24 13:12:09    阅读次数:68
236. 二叉树的最近公共祖先
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), ...
分类:其他好文   时间:2020-03-24 12:59:17    阅读次数:54
【LeetCode】二叉树的最近公共祖先(2)
对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。两道题分别针对二叉搜索树和普通的二叉树实现对最近公共祖先的查找。 ...
分类:其他好文   时间:2020-03-21 19:39:04    阅读次数:72
1958条   上一页 1 ... 27 28 29 30 31 ... 196 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!