After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 127 KiB |
@ -0,0 +1,28 @@
|
|||||||
|
### 将树转化为数组
|
||||||
|
- static List<Integer> kminArray(TreeNode root){
|
||||||
|
List<Integer> array=new ArrayList<>();
|
||||||
|
if(root==null){
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
//利用递归法,将树转化为数组
|
||||||
|
array.addAll(kminArray(root.left));//牛
|
||||||
|
array.add(root.val);
|
||||||
|
array.addAll(kminArray(root.right));
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
### 树的创建方法-队列
|
||||||
|
- static TreeNode createTree(int rootIndex, Integer[] values) {
|
||||||
|
if (rootIndex >= values.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (values[rootIndex] == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
TreeNode rootNode = new TreeNode();
|
||||||
|
rootNode.val = values[rootIndex];
|
||||||
|
rootNode.left = createTree(2 * rootIndex + 1, values);
|
||||||
|
rootNode.right = createTree(2 * rootIndex + 2, values);
|
||||||
|
return rootNode;//返回根节点
|
||||||
|
}
|
||||||
|
-
|
@ -0,0 +1,9 @@
|
|||||||
|
### 内部类
|
||||||
|
- 
|
||||||
|
|
||||||
|
### 集合结构
|
||||||
|

|
||||||
|
|
||||||
|
### map
|
||||||
|

|
||||||
|
- Treemap 是红黑树
|