不为成仙,只为在这红尘中等你回来。

堆排序

    ### 堆排序前传 - 树与二叉树 - 树是一种数据结构(目录结构) - 树是一种可以递归定义的数据结构 - 树是由 n 个节点组成的集合 - 如果 n = 0,那这是一颗空树 - 如果 n > 0,那存在1个节点作为树的根节点,其它节点可以分为 m 个集合,每个集合本身又是一棵树 ### 堆 - 堆是一种特殊的完全二叉树 - 大根堆:一颗完全二叉树,满足任一节点都比其孩子节点大 - 小根堆,一颗完全二叉树,满足任一节点都比其孩子节点小 ### 堆排序过...

    阅读全文>>

2020年11月5日 23:19 作者:nancy 分类:[算法与数据结构] 1077

107. Binary Tree Level Order Traversal II [Easy]

    ### 题意 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 example: Given binary tre...

    阅读全文>>

2018年5月29日 10:24 作者:nancy 分类:[LeetCode] 1405

257. Binary Tree Paths [Easy]

    ### 题意 Given a binary tree, return all root-to-leaf paths. 给定一个二叉树,返回所有从根节点到叶子节点的路径。 Note: A leaf is a node with no children. 说明: 叶子节点是指没有子节点的节点。 Example: ``` Input: 1 / \ 2 3 \ 5 Output: ["1->2->5", "1->3"] ...

    阅读全文>>

2018年5月25日 12:15 作者:nancy 分类:[LeetCode] 1431

112. Path Sum [Easy]

    ### 题意 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. 给定一个二叉树和一个目标和,判断该树中是否存在根节点到叶子节点的路径,这条路径上所有节点值相加等于目标和。 Note: A leaf is a node with no...

    阅读全文>>

2018年5月25日 09:17 作者:nancy 分类:[LeetCode] 1420

111. Minimum Depth of Binary Tree [Easy]

    ### 题意 Given a binary tree, find its minimum depth. 给定一个二叉树,找出其最小深度。 The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。 Note: A leaf is a nod...

    阅读全文>>

2018年5月24日 10:20 作者:nancy 分类:[LeetCode] 1371

110. Balanced Binary Tree [Easy]

    ### 题意 Given a binary tree, determine if it is height-balanced. 给定一个二叉树,判断它是否是高度平衡的二叉树。 For this problem, a height-balanced binary tree is defined as: 本题中,一棵高度平衡二叉树定义为: a binary tree in which the depth of the two subtrees of every nod...

    阅读全文>>

2018年5月24日 09:57 作者:nancy 分类:[LeetCode] 1327

108. Convert Sorted Array to Binary Search Tree [Easy]

    ### 题意 Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树。 For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the tw...

    阅读全文>>

2018年5月23日 10:01 作者:nancy 分类:[LeetCode] 1366

104. Maximum Depth of Binary Tree [Easy]

    ### 题意 Given a binary tree, find its maximum depth. 给定一个二叉树,找出其最大深度。 The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 Note: A leaf is a nod...

    阅读全文>>

2018年5月23日 09:44 作者:nancy 分类:[LeetCode] 1361

101. Symmetric Tree [Easy]

    ### 题意 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). 给定一个二叉树,检查它是否是镜像对称的。 For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 例如,二叉树 [1,2,2,3,4,4,3] 是对称的。 ``` 1 / \ 2 ...

    阅读全文>>

2018年5月22日 10:35 作者:nancy 分类:[LeetCode] 1359

100. Same Tree [Easy]

    ### 题意 Given two binary trees, write a function to check if they are the same or not. 给定两个二叉树,编写一个函数来检验它们是否相同。 Two binary trees are considered the same if they are structurally identical and the nodes have the same value. 如果两个树在结构上相同,并且节...

    阅读全文>>

2018年5月22日 09:45 作者:nancy 分类:[LeetCode] 1454