码迷,mamicode.com
首页 >  
搜索关键字:easyui treegrid treenode    ( 5856个结果
108. 将有序数组转换为二叉搜索树(C++)
题目 将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树。 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。 示例: 给定有序数组: [-10,-3,0,5,9], 一个可能的答案是:[0,-3,9,-10,null,5],它可以表示下面这个高度平 ...
分类:编程语言   时间:2020-09-16 12:21:04    阅读次数:31
判断B是 A的子树
解析:https://leetcode-cn.com/problems/shu-de-zi-jie-gou-lcof/solution/mian-shi-ti-26-shu-de-zi-jie-gou-xian-xu-bian-li-p/ bool isSubStructure(TreeNode* ...
分类:其他好文   时间:2020-09-16 12:19:57    阅读次数:34
二叉树前中后序非递归遍历
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r ...
分类:其他好文   时间:2020-09-16 12:19:36    阅读次数:29
450. Delete Node in a BST - Medium
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of th ...
分类:其他好文   时间:2020-09-15 21:24:11    阅读次数:42
Java二叉树非递归实现
//前序遍历 /** * 根-左-右,所以入栈的时候要相反,有右节点则加入右节点,有左节点则加入左节点,每车循环的时候,弹一个 */ public ArrayList<Integer> preorderTraversal(TreeNode root) { ArrayList<Integer> lis ...
分类:编程语言   时间:2020-09-11 14:23:16    阅读次数:41
222. 完全二叉树的节点个数
class Solution(object): # 递归思路: # (1)如果二叉树为空,节点个数为0 # (2)如果二叉树不为空,二叉树节点个数 = 左子树节点个数 + 右子树节点个数 + 1 def countNodes(self, root): """ :type root: TreeNode ...
分类:其他好文   时间:2020-09-11 14:10:52    阅读次数:39
26、二叉搜索树与双向链表
输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。 Python # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.r ...
分类:其他好文   时间:2020-09-02 16:53:04    阅读次数:42
层次遍历构造二叉树
二叉树节点函数定义: /** * Definition for a binary tree node. */ function TreeNode(val){ this.val = val; this.left = this.right = null; } 层次遍历构建二叉树(广度优先) functi ...
分类:其他好文   时间:2020-08-26 18:35:16    阅读次数:74
【leetcode】平衡二叉树
int height(struct TreeNode* root) { if (root == NULL) { return 0; } else { return fmax(height(root->left), height(root->right)) + 1; } } bool isBalanc ...
分类:其他好文   时间:2020-08-19 19:58:57    阅读次数:65
leetcode94 - Binary Tree Inorder Traversal - medium
Given a binary tree, return the inorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,3,2] Follow up: Recursive so ...
分类:其他好文   时间:2020-08-17 17:50:25    阅读次数:81
5856条   上一页 1 ... 8 9 10 11 12 ... 586 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!