一、分类 1、二叉查找树 (1)左子树不为空,并且左子树所有结点的值小于根节点的值 (2)右子树不为空,并且右子树所有节点的值大于根节点的值 (3)左右子树也分别是二叉排序树 (4)没有键值相等的结点 2、平衡二叉树(AVL) 左右两个子树的高度差不超过一,并且左右两个子树也都是平衡二叉树 3、红黑树 (1)每个结点要么是红的要不是黑的 (2)根结点必须是黑的 (3)叶子结点必须是黑的 (4)如果

java   二叉树   总结   面试   笔试  

一、原题 Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We use#as a separator for each node,

LeetCode   java   DFS   BFS  

一、原题 There are N gas stations along a circular route, where the amount of gas at station i isgas[i]. You have a car with an unlimited gas tank and it costscost[i]of gas to travel from station i to its

java   LeetCode  

一、原题 There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at least one

LeetCode   java   小朋友分糖  

一、原题 Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without us

LeetCode   java   位与  

一、原题 A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. 一、中文 链表的每个元素不仅有指向下一个结点的指针,还包括了一

LeetCode   java   单链表   深拷贝  

一、原题 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 node never di

LeetCode   java   二叉树  

一、原题 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,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7 1

遍历   LeetCode   java  

一、原题 Given a binary tree, return the inorder traversal of its nodes values.  一、中文 二叉树的前序、中序、后序三种遍历方式的总结 三、举例 前序:根-左-右 中序:左-根-右 后序:左-右-根 四、思路   每一种遍历方式都有两种方式,一种是递归,一种是非递归的方式,递归很简单,下面主要是非递归的方式 (1)前序 首先建

LeetCode   java  

一、原题 Reverse a linked list from position m to n. Do it in-place and in one-pass.  For example:  Given 1->2->3->4->5->NULL, m = 2 and n = 4,  return 1->4->3->2->5->NULL.  二、中文 给定一个单链表,将第m到第n个之间的元素进行转 

LeetCode   单链表   java  
1 2 3 4 5 6