Merge pull request #2 from CyC2018/master

Update
This commit is contained in:
Xie Wei 2019-02-21 22:45:57 +08:00 committed by GitHub
commit cbcf527643
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
107 changed files with 97 additions and 150 deletions

View File

@ -1,5 +1,5 @@
> [🍉 点击阅读面试进阶指南](https://github.com/CyC2018/Backend-Interview-Guide)
> [点击阅读面试进阶指南](https://github.com/CyC2018/Backend-Interview-Guide)
## ✏️ 算法

View File

@ -61,7 +61,7 @@ pre {
@media (min-width:600px) {
pre code {
box-shadow: 2px 1px 20px 2px #aaa;
/*box-shadow: 2px 1px 20px 2px #aaa;*/
/*border-radius: 10px !important;*/
padding-left: 20px !important;
}
@ -72,4 +72,10 @@ pre {
padding-left: 0px !important;
padding-right: 0px !important;
}
}
.markdown-section pre {
padding-left: 0 !important;
padding-right: 0px !important;
box-shadow: 2px 1px 20px 2px #aaa;
}

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、解决的问题](#一解决的问题)
* [二、与虚拟机的比较](#二与虚拟机的比较)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [集中式与分布式](#集中式与分布式)
* [中心服务器](#中心服务器)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一 、基础概念](#一-基础概念)
* [URI](#uri)
@ -67,7 +67,7 @@ URI 包含 URL 和 URN。
- URLUniform Resource Locator统一资源定位符
- URNUniform Resource Name统一资源名称
<div align="center"> <img src="pics/766d401b-3cf6-475c-8ced-ea8c8db8edc5.png" width="700"/> </div><br>
<div align="center"> <img src="pics/1_2001550415765493.png" width="500px"> </div><br>
## 请求和响应报文

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、概览](#一概览)
* [二、磁盘操作](#二磁盘操作)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、数据类型](#一数据类型)
* [基本类型](#基本类型)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、概览](#一概览)
* [Collection](#collection)
@ -15,7 +15,6 @@
* [ConcurrentHashMap](#concurrenthashmap)
* [LinkedHashMap](#linkedhashmap)
* [WeakHashMap](#weakhashmap)
* [附录](#附录)
* [参考资料](#参考资料)
<!-- GFM-TOC -->
@ -26,7 +25,8 @@
## Collection
<div align="center"> <img src="pics/6_200.png"/> </div><br>
<div align="center"> <img src="pics/6_2001550476096035.png"/> </div><br>
### 1. Set
@ -52,7 +52,7 @@
## Map
<div align="center"> <img src="pics/7_200.png"/> </div><br>
<div align="center"> <img src="pics/2_2001550426232419.png"/> </div><br>
- TreeMap基于红黑树实现。
@ -1097,90 +1097,6 @@ public final class ConcurrentCache<K, V> {
}
```
# 附录
Collection 绘图源码:
```
@startuml
interface Collection
interface Set
interface List
interface Queue
interface SortSet
class HashSet
class LinkedHashSet
class TreeSet
class ArrayList
class Vector
class LinkedList
class PriorityQueue
Collection <|-- Set
Collection <|-- List
Collection <|-- Queue
Set <|-- SortSet
Set <|.. HashSet
Set <|.. LinkedHashSet
SortSet <|.. TreeSet
List <|.. ArrayList
List <|.. Vector
List <|.. LinkedList
Queue <|.. LinkedList
Queue <|.. PriorityQueue
@enduml
```
Map 绘图源码
```
@startuml
interface Map
interface SortMap
class HashTable
class LinkedHashMap
class HashMap
class TreeMap
Map <|.. HashTable
Map <|.. LinkedHashMap
Map <|.. HashMap
Map <|-- SortMap
SortMap <|.. TreeMap
@enduml
```
迭代器类图
```
@startuml
interface Iterable
interface Collection
interface List
interface Set
interface Queue
interface Iterator
interface ListIterator
Iterable <|-- Collection
Collection <|.. List
Collection <|.. Set
Collection <|-- Queue
Iterator <-- Iterable
Iterator <|.. ListIterator
ListIterator <-- List
@enduml
```
# 参考资料

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、线程状态转换](#一线程状态转换)
* [新建New](#新建new)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、运行时数据区域](#一运行时数据区域)
* [程序计数器](#程序计数器)
@ -60,7 +60,7 @@ java -Xss512M HackTheJava
本地方法一般是用其它语言C、C++ 或汇编语言等)编写的,并且被编译为基于本机硬件和操作系统的程序,对待这些方法需要特别处理。
<div align="center"> <img src="pics/3034859c-eb5a-402b-b65a-974dcc0c4a46.png"/> </div><br>
<div align="center"> <img src="pics/1_2001550547261811.png"/> </div><br>
## 堆
@ -220,7 +220,8 @@ obj = null;
### 1. 标记 - 清除
<div align="center"> <img src="pics/3fb6e997-0fc9-4178-a691-5907b67bbeae.png"/> </div><br>
<div align="center"> <img src="pics/3_2001550547558008.png"/> </div><br>
标记要回收的对象,然后清除。
@ -231,13 +232,15 @@ obj = null;
### 2. 标记 - 整理
<div align="center"> <img src="pics/fb14b808-734c-4634-9c87-e598b1937996.png"/> </div><br>
<div align="center"> <img src="pics/2_2001550547456403.png"/> </div><br>
让所有存活的对象都向一端移动,然后直接清理掉端边界以外的内存。
### 3. 复制
<div align="center"> <img src="pics/3f04455c-f4ac-4038-a69f-21df133389e1.png"/> </div><br>
<div align="center"> <img src="pics/4_2001550547640585.png"/> </div><br>
将内存划分为大小相等的两块,每次只使用其中一块,当这一块内存用完了就将还存活的对象复制到另一块上面,然后再把使用过的内存空间进行一次清理。

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [算法思想](#算法思想)
* [双指针](#双指针)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [595. Big Countries](#595-big-countries)
* [627. Swap Salary](#627-swap-salary)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、常用操作以及概念](#一常用操作以及概念)
* [快捷键](#快捷键)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、索引](#一索引)
* [B+ Tree 原理](#b-tree-原理)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、概述](#一概述)
* [二、数据类型](#二数据类型)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、基础](#一基础)
* [二、创建表](#二创建表)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、I/O 模型](#一io-模型)
* [阻塞式 I/O](#阻塞式-io)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
docs/notes/pics/11_200.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
docs/notes/pics/8_200.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
docs/notes/pics/9_200.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、可读性的重要性](#一可读性的重要性)
* [二、用名字表达代码含义](#二用名字表达代码含义)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
<!-- GFM-TOC -->

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、分布式锁](#一分布式锁)
* [数据库的唯一索引](#数据库的唯一索引)
@ -314,19 +314,19 @@ Raft 也是分布式一致性协议,主要是用来竞选主节点。
- 来自客户端的修改都会被传入 Leader。注意该修改还未被提交只是写入日志中。
<div align="center"> <img src="pics/7.gif"/> </div><br>
<div align="center"> <img src="pics/71550414107576.gif"/> </div><br>
- Leader 会把修改复制到所有 Follower。
<div align="center"> <img src="pics/9.gif"/> </div><br>
<div align="center"> <img src="pics/91550414131331.gif"/> </div><br>
- Leader 会等待大多数的 Follower 也进行了修改,然后才将修改提交。
<div align="center"> <img src="pics/10.gif"/> </div><br>
<div align="center"> <img src="pics/101550414151983.gif"/> </div><br>
- 此时 Leader 会通知的所有 Follower 让它们也提交修改,此时所有节点的值达成一致。
<div align="center"> <img src="pics/11.gif"/> </div><br>
<div align="center"> <img src="pics/111550414182638.gif"/> </div><br>
# 参考

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [3. 数组中重复的数字](#3-数组中重复的数字)
* [4. 二维数组中的查找](#4-二维数组中的查找)
@ -510,6 +510,8 @@ public class Solution {
一只青蛙一次可以跳上 1 级台阶,也可以跳上 2 级。求该青蛙跳上一个 n 级的台阶总共有多少种跳法。
<div align="center"> <img src="pics/1_2001550465428749.png"/> </div><br>
## 解题思路
```java
@ -535,6 +537,8 @@ public int JumpFloor(int n) {
我们可以用 2\*1 的小矩形横着或者竖着去覆盖更大的矩形。请问用 n 个 2\*1 的小矩形无重叠地覆盖一个 2\*n 的大矩形,总共有多少种方法?
<div align="center"> <img src="pics/11550465817827.gif"/> </div><br>
## 解题思路
```java
@ -560,6 +564,8 @@ public int RectCover(int n) {
一只青蛙一次可以跳上 1 级台阶,也可以跳上 2 级... 它也可以跳上 n 级。求该青蛙跳上一个 n 级的台阶总共有多少种跳法。
<div align="center"> <img src="pics/21550465890674.gif"/> </div><br>
## 解题思路
### 动态规划
@ -682,7 +688,7 @@ private int minNumber(int[] nums, int l, int h) {
例如下面的矩阵包含了一条 bfce 路径。
<div align="center"> <img src="pics/e31abb94-9201-4e06-9902-61101b92f475.png" width="300"/> </div><br>
<div align="center"> <img src="pics/2_2001550466182933.png"/> </div><br>
## 解题思路
@ -961,6 +967,8 @@ private void printNumber(char[] number) {
<div align="center"> <img src="pics/27ff9548-edb6-4465-92c8-7e6386e0b185.png" width="600"/> </div><br>
② 如果链表只有一个节点,那么直接
② 否则,就需要先遍历链表,找到节点的前一个节点,然后让前一个节点指向 null时间复杂度为 O(N)。
<div align="center"> <img src="pics/280f7728-594f-4811-a03a-fa8d32c013da.png" width="600"/> </div><br>
@ -977,10 +985,15 @@ public ListNode deleteNode(ListNode head, ListNode tobeDelete) {
tobeDelete.val = next.val;
tobeDelete.next = next.next;
} else {
ListNode cur = head;
while (cur.next != tobeDelete)
cur = cur.next;
cur.next = null;
if (head == tobeDelete)
// 只有一个节点
head = null;
else {
ListNode cur = head;
while (cur.next != tobeDelete)
cur = cur.next;
cur.next = null;
}
}
return head;
}
@ -1109,6 +1122,8 @@ public boolean isNumeric(char[] str) {
需要保证奇数和奇数,偶数和偶数之间的相对位置不变,这和书本不太一样。
<div align="center"> <img src="pics/7_2001550475133282.png"/> </div><br>
## 解题思路
```java
@ -1369,7 +1384,7 @@ boolean isSymmetrical(TreeNode t1, TreeNode t2) {
下图的矩阵顺时针打印结果为1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10
<div align="center"> <img src="pics/6539b9a4-2b24-4d10-8c94-2eb5aba1e296.png" width="300"/> </div><br>
<div align="center"> <img src="pics/8_2001550475451664.png"/> </div><br>
## 解题思路
@ -2719,6 +2734,8 @@ public ArrayList<Integer> maxInWindows(int[] num, int size) {
把 n 个骰子仍在地上,求点数和为 s 的概率。
<div align="center"> <img src="pics/6_2001550474388460.png"/> </div><br>
## 解题思路
### 动态规划解法
@ -2790,6 +2807,8 @@ public List<Map.Entry<Integer, Double>> dicesSum(int n) {
五张牌,其中大小鬼为癞子,牌面大小为 0。判断这五张牌是否能组成顺子。
<div align="center"> <img src="pics/5_2001550474110029.png"/> </div><br>
## 解题思路
```java
@ -2847,6 +2866,8 @@ public int LastRemaining_Solution(int n, int m) {
可以有一次买入和一次卖出,那么买入必须在前。求最大收益。
<div align="center"> <img src="pics/4_2001550473915641.png"/> </div><br>
## 解题思路
使用贪心策略,假设第 i 轮进行卖出操作,买入操作价格应该在 i 之前并且价格最低。
@ -2917,6 +2938,8 @@ public int Add(int a, int b) {
给定一个数组 A[0, 1,..., n-1],请构建一个数组 B[0, 1,..., n-1],其中 B 中的元素 B[i]=A[0]\*A[1]\*...\*A[i-1]\*A[i+1]\*...\*A[n-1]。要求不能使用除法。
<div align="center"> <img src="pics/3_2001550473624627.png"/> </div><br>
## 解题思路
```java

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、跨站脚本攻击](#一跨站脚本攻击)
* [二、跨站请求伪造](#二跨站请求伪造)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、事务](#一事务)
* [概念](#概念)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、构建工具的作用](#一构建工具的作用)
* [二、Java 主流构建工具](#二java-主流构建工具)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、概述](#一概述)
* [二、匹配单个字符](#二匹配单个字符)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、消息模型](#一消息模型)
* [点对点](#点对点)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、前言](#一前言)
* [二、算法分析](#二算法分析)
@ -646,7 +646,7 @@ public T select(T[] nums, int k) {
堆可以用数组来表示,这是因为堆是完全二叉树,而完全二叉树很容易就存储在数组中。位置 k 的节点的父节点位置为 k/2而它的两个子节点的位置分别为 2k 和 2k+1。这里不使用数组索引为 0 的位置,是为了更清晰地描述节点的位置关系。
<div align="center"> <img src="pics/f3080f83-6239-459b-8e9c-03b6641f7815.png" width="200"/> </div><br>
<div align="center"> <img src="pics/8_200.png"/> </div><br>
```java
public class Heap<T extends Comparable<T>> {
@ -682,7 +682,7 @@ public class Heap<T extends Comparable<T>> {
在堆中,当一个节点比父节点大,那么需要交换这个两个节点。交换后还可能比它新的父节点大,因此需要不断地进行比较和交换操作,把这种操作称为上浮。
<div align="center"> <img src="pics/33ac2b23-cb85-4e99-bc41-b7b7199fad1c.png" width="400"/> </div><br>
<div align="center"> <img src="pics/81550405360028.gif"/> </div><br>
```java
private void swim(int k) {
@ -695,7 +695,7 @@ private void swim(int k) {
类似地,当一个节点比子节点来得小,也需要不断地向下进行比较和交换操作,把这种操作称为下沉。一个节点如果有两个子节点,应当与两个子节点中最大那个节点进行交换。
<div align="center"> <img src="pics/72f0ff69-138d-4e54-b7ac-ebe025d978dc.png" width="400"/> </div><br>
<div align="center"> <img src="pics/91550405374894.gif"/> </div><br>
```java
private void sink(int k) {
@ -744,15 +744,13 @@ public T delMax() {
无序数组建立堆最直接的方法是从左到右遍历数组进行上浮操作。一个更高效的方法是从右至左进行下沉操作,如果一个节点的两个节点都已经是堆有序,那么进行下沉操作可以使得这个节点为根节点的堆有序。叶子节点不需要进行下沉操作,可以忽略叶子节点的元素,因此只需要遍历一半的元素即可。
<div align="center"> <img src="pics/b84ba6fb-312b-4e69-8c77-fb6eb6fb38d4.png" width="300"/> </div><br>
<div align="center"> <img src="pics/101550406418006.gif"/> </div><br>
#### 5.2 交换堆顶元素与最后一个元素
交换之后需要进行下沉操作维持堆的有序状态。
<div align="center"> <img src="pics/51fb761d-8ce0-4472-92ff-2f227ac7888a.png" width="270"/> </div><br>
<div align="center"> <img src="pics/b20a3466-44b4-445e-87c7-dd4fb9ef44b2.png" width="350"/> </div><br>
<div align="center"> <img src="pics/111550407277293.gif"/> </div><br>
```java
public class HeapSort<T extends Comparable<T>> extends Sort<T> {
@ -2045,7 +2043,7 @@ public class Transaction {
对于 N 个键M 条链表 (N>M),如果哈希函数能够满足均匀性的条件,每条链表的大小趋向于 N/M因此未命中的查找和插入操作所需要的比较次数为 \~N/M。
<div align="center"> <img src="pics/b4252c85-6fb0-4995-9a68-a1a5925fbdb1.png" width="300"/> </div><br>
<div align="center"> <img src="pics/9_200.png"/> </div><br>
### 3. 线性探测法
@ -2053,7 +2051,7 @@ public class Transaction {
使用线性探测法,数组的大小 M 应当大于键的个数 NM>N)。
<div align="center"> <img src="pics/dbb8516d-37ba-4e2c-b26b-eefd7de21b45.png" width="400"/> </div><br>
<div align="center"> <img src="pics/121550407878282.gif"/> </div><br>
```java
public class LinearProbingHashST<Key, Value> implements UnorderedST<Key, Value> {
@ -2154,7 +2152,7 @@ public void delete(Key key) {
线性探测法的成本取决于连续条目的长度,连续条目也叫聚簇。当聚簇很长时,在查找和插入时也需要进行很多次探测。例如下图中 2\~5 位置就是一个聚簇。
<div align="center"> <img src="pics/386cd64f-7a9d-40e6-8c55-22b90ee2d258.png" width="400"/> </div><br>
<div align="center"> <img src="pics/11_200.png"/> </div><br>
α = N/Mα 称为使用率。理论证明,当 α 小于 1/2 时探测的预计次数只在 1.5 到 2.5 之间。为了保证散列表的性能,应当调整数组的大小,使得 α 在 [1/4, 1/2] 之间。

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、性能](#一性能)
* [二、伸缩性](#二伸缩性)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、缓存特征](#一缓存特征)
* [二、LRU](#二lru)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、概述](#一概述)
* [基本特征](#基本特征)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、概述](#一概述)
* [网络的网络](#网络的网络)
@ -660,11 +660,13 @@ TCP 使用超时重传来实现可靠传输:如果一个已经发送的报文
<div align="center"><img src="https://latex.codecogs.com/gif.latex?RTTs=(1-a)*(RTTs)+a*RTT"/></div> <br>
其中0 ≤ a 1RTTs 随着 a 的增加更容易受到 RTT 的影响。
超时时间 RTO 应该略大于 RTTsTCP 使用的超时时间计算如下:
<div align="center"><img src="https://latex.codecogs.com/gif.latex?RTO=RTTs+4*RTT_d"/></div> <br>
其中 RTT<sub>d</sub> 为偏差。
其中 RTT<sub>d</sub> 为偏差的加权平均值
## TCP 滑动窗口

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、概述](#一概述)
* [二、创建型](#二创建型)

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、负载均衡](#一负载均衡)
* [负载均衡算法](#负载均衡算法)
@ -95,7 +95,7 @@ HTTP 重定向负载均衡服务器使用某种负载均衡算法计算得到服
该负载均衡转发的缺点比较明显,实际场景中很少使用它。
<div align="center"> <img src="pics/82a6981a-17aa-4370-b645-8704f44fc4a9.jpg"/> </div><br>
<div align="center"> <img src="pics/131550414680831.gif"/> </div><br>
### 2. DNS 域名解析
@ -111,7 +111,7 @@ HTTP 重定向负载均衡服务器使用某种负载均衡算法计算得到服
大型网站基本使用了 DNS 做为第一级负载均衡手段,然后在内部使用其它方式做第二级负载均衡。也就是说,域名解析的结果为内部的负载均衡服务器 IP 地址。
<div align="center"> <img src="pics/5d0cb407-f1cc-4b89-ad4a-ec4e9b327c34.jpg"/> </div><br>
<div align="center"> <img src="pics/141550414746389.gif"/> </div><br>
### 3. 反向代理服务器

View File

@ -1,4 +1,4 @@
[🍉 点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
* [点击阅读面试进阶指南 ](https://github.com/CyC2018/Backend-Interview-Guide)
<!-- GFM-TOC -->
* [一、三大特性](#一三大特性)
* [封装](#封装)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
docs/pics/11_200.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Some files were not shown because too many files have changed in this diff Show More