Skip to content

Commit 8fec437

Browse files
authored
Merge pull request geekxh#62 from geekxh/feature/0726
Feature/0726
2 parents ffd1253 + 878ffbc commit 8fec437

File tree

1,257 files changed

+8511
-724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,257 files changed

+8511
-724
lines changed

1.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
##### [点击下载本项目全部内容 提取码:【8f8b】 包括:1、我写的图解算法题典 2、千本开源电子书 3、百张思维导图 4、BAT/TMD 大厂面经 (如果链接失效,上方扫码回复即可)](https://www.geekxh.com/github_click.html?6072)
2+
3+
#### 本项目还包括 I(支持下载):
4+
5+
> 千本开源电子书覆盖了你在IT行业发展可以用到的大部分资料,百张思维导图按照专题对各类计算机知识进行了整合。**由于文件过大,建议通过下方扫码,回复【999】获取**
6+
7+
- 📚 [一千本开源电子书](https://github.com/geekxh/hello-algorithm/tree/master/%E6%B8%85%E6%99%B0%E7%89%88%E7%94%B5%E5%AD%90%E4%B9%A61000%E6%9C%AC)
8+
- 🐒 [百张思维导图集锦](https://github.com/geekxh/hello-algorithm/tree/master/%E8%B6%85%E6%B8%85%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE100%E5%BC%A0)
9+
10+
#### 本项目还包括 II(支持下载):
11+
12+
> 大厂面经汇总覆盖了阿里、京东、华为、字节、滴滴、百度、美团、腾讯 等公司的面试题,按照 公司/专题 两个维度对面试题进行了整合。**由于文件过大,建议通过下方扫码,回复【面经】获取。**
13+
14+
<br/>
15+
<div align="center">
16+
<a href="https://www.geekxh.com/readme/04.png" style="box-shadow: rgb(210, 210, 210) 0em 0em 0.5em 0px; font-size: 17px;"><img src="https://www.geekxh.com/readme/04.png" width="200px"></a>
17+
</div>
18+
<br/>
19+
20+
### 使用指南
21+
22+
1、因为本教程完全免费,但现在被一些不良商家拿去卖钱,<b> 所以我需要你先帮我点一个 star </b>,助力原创,防止更多人上当受骗,也顺便支持我一下。
23+
24+
2、算法训练包括三部分:① 算法知识基础 ② 图解算法题典 ③ 算法知识扩展
25+
26+
3、如果是以面试为目的,可以直接对第二部分进行学习。如果基础薄弱,建议从第一部分进行学习。第三部分为专题学习,包含大部分算法资料。
27+
28+
4、对于其中题目有疑惑,可以加入我们的<b>万人刷题群</b>,群里可内推 BAT。扫上面那只熊,回复【进群】即可。
29+
30+
5、当然,也许你就想加我的私人微信: [个人名片](https://www.geekxh.com/contact.jpeg)
31+
32+
PS:该项目包括了你在 IT 行业发展可以用到的绝大部分资料。但我希望大家不要当收藏党,找到适合自己的才重要。

PART_1_算法基础/1_数据结构知识框架/README.md

+642
Large diffs are not rendered by default.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# 双向链表
2+
3+
在计算机科学中, 一个 **双向链表(doubly linked list)** 是由一组称为节点的顺序链接记录组成的链接数据结构。每个节点包含两个字段,称为链接,它们是对节点序列中上一个节点和下一个节点的引用。开始节点和结束节点的上一个链接和下一个链接分别指向某种终止节点,通常是前哨节点或null,以方便遍历列表。如果只有一个前哨节点,则列表通过前哨节点循环链接。它可以被概念化为两个由相同数据项组成的单链表,但顺序相反。
4+
5+
![Doubly Linked List](https://upload.wikimedia.org/wikipedia/commons/5/5e/Doubly-linked-list.svg)
6+
7+
两个节点链接允许在任一方向上遍历列表。
8+
9+
在双向链表中进行添加或者删除节点时,需做的链接更改要比单向链表复杂得多。这种操作在单向链表中更简单高效,因为不需要关注一个节点(除第一个和最后一个节点以外的节点)的两个链接,而只需要关注一个链接即可。
10+
11+
12+
13+
## 基础操作的伪代码
14+
15+
### 插入
16+
17+
```text
18+
Add(value)
19+
Pre: value is the value to add to the list
20+
Post: value has been placed at the tail of the list
21+
n ← node(value)
22+
if head = ø
23+
head ← n
24+
tail ← n
25+
else
26+
n.previous ← tail
27+
tail.next ← n
28+
tail ← n
29+
end if
30+
end Add
31+
```
32+
33+
### 删除
34+
35+
```text
36+
Remove(head, value)
37+
Pre: head is the head node in the list
38+
value is the value to remove from the list
39+
Post: value is removed from the list, true; otherwise false
40+
if head = ø
41+
return false
42+
end if
43+
if value = head.value
44+
if head = tail
45+
head ← ø
46+
tail ← ø
47+
else
48+
head ← head.next
49+
head.previous ← ø
50+
end if
51+
return true
52+
end if
53+
n ← head.next
54+
while n = ø and value !== n.value
55+
n ← n.next
56+
end while
57+
if n = tail
58+
tail ← tail.previous
59+
tail.next ← ø
60+
return true
61+
else if n = ø
62+
n.previous.next ← n.next
63+
n.next.previous ← n.previous
64+
return true
65+
end if
66+
return false
67+
end Remove
68+
```
69+
70+
### 反向遍历
71+
72+
```text
73+
ReverseTraversal(tail)
74+
Pre: tail is the node of the list to traverse
75+
Post: the list has been traversed in reverse order
76+
n ← tail
77+
while n = ø
78+
yield n.value
79+
n ← n.previous
80+
end while
81+
end Reverse Traversal
82+
```
83+
84+
## 复杂度
85+
86+
## 时间复杂度
87+
88+
| Access | Search | Insertion | Deletion |
89+
| :-------: | :-------: | :-------: | :-------: |
90+
| O(n) | O(n) | O(1) | O(1) |
91+
92+
### 空间复杂度
93+
94+
O(n)
95+
96+
## 参考
97+
98+
- [Wikipedia](https://en.wikipedia.org/wiki/Doubly_linked_list)
99+
- [YouTube](https://www.youtube.com/watch?v=JdQeNxWCguQ&t=7s&index=72&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
3+
在计算机科学中, **图(graph)** 是一种抽象数据类型,
4+
旨在实现数学中的无向图和有向图概念,特别是图论领域。
5+
6+
一个图数据结构是一个(由有限个或者可变数量的)顶点/节点/点和边构成的有限集。
7+
8+
如果顶点对之间是无序的,称为无序图,否则称为有序图;
9+
10+
如果顶点对之间的边是没有方向的,称为无向图,否则称为有向图;
11+
12+
如果顶点对之间的边是有权重的,该图可称为加权图。
13+
14+
15+
16+
![Graph](https://www.tutorialspoint.com/data_structures_algorithms/images/graph.jpg)
17+
18+
## 参考
19+
20+
- [Wikipedia](https://en.wikipedia.org/wiki/Graph_(abstract_data_type))
21+
- [Introduction to Graphs on YouTube](https://www.youtube.com/watch?v=gXgEDyodOJU&index=9&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
22+
- [Graphs representation on YouTube](https://www.youtube.com/watch?v=k1wraWzqtvQ&index=10&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 哈希表
2+
3+
在计算中, 一个 **哈希表(hash table 或hash map)** 是一种实现 *关联数组(associative array)*
4+
的抽象数据;类型, 该结构可以将 *键映射到值*
5+
6+
哈希表使用 *哈希函数/散列函数* 来计算一个值在数组或桶(buckets)中或槽(slots)中对应的索引,可使用该索引找到所需的值。
7+
8+
理想情况下,散列函数将为每个键分配给一个唯一的桶(bucket),但是大多数哈希表设计采用不完美的散列函数,这可能会导致"哈希冲突(hash collisions)",也就是散列函数为多个键(key)生成了相同的索引,这种碰撞必须
9+
以某种方式进行处理。
10+
11+
12+
![Hash Table](https://upload.wikimedia.org/wikipedia/commons/7/7d/Hash_table_3_1_1_0_1_0_0_SP.svg)
13+
14+
通过单独的链接解决哈希冲突
15+
16+
![Hash Collision](https://upload.wikimedia.org/wikipedia/commons/d/d0/Hash_table_5_0_1_1_1_1_1_LL.svg)
17+
18+
## 参考
19+
20+
- [Wikipedia](https://en.wikipedia.org/wiki/Hash_table)
21+
- [YouTube](https://www.youtube.com/watch?v=shs0KM3wKv8&index=4&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 堆 (数据结构)
2+
3+
在计算机科学中, 一个 **堆(heap)** 是一种特殊的基于树的数据结构,它满足下面描述的堆属性。
4+
5+
在一个 *最小堆(min heap)* 中, 如果 `P``C` 的一个父级节点, 那么 `P` 的key(或value)应小于或等于 `C` 的对应值.
6+
7+
![最小堆](https://upload.wikimedia.org/wikipedia/commons/6/69/Min-heap.png)
8+
9+
在一个 *最大堆(max heap)* 中, `P` 的key(或value)大于 `C` 的对应值。
10+
11+
![](https://upload.wikimedia.org/wikipedia/commons/3/38/Max-Heap.svg)
12+
13+
14+
在堆“顶部”的没有父级节点的节点,被称之为根节点。
15+
16+
## 参考
17+
18+
- [Wikipedia](https://en.wikipedia.org/wiki/Heap_(data_structure))
19+
- [YouTube](https://www.youtube.com/watch?v=t0Cq6tVNRBA&index=5&t=0s&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# 链表
2+
3+
在计算机科学中, 一个 **链表** 是数据元素的线性集合, 元素的线性顺序不是由它们在内存中的物理位置给出的。 相反, 每个元素指向下一个元素。它是由一组节点组成的数据结构,这些节点一起,表示序列。
4+
5+
在最简单的形式下,每个节点由数据和到序列中下一个节点的引用(换句话说,链接)组成。这种结构允许在迭代期间有效地从序列中的任何位置插入或删除元素。
6+
7+
更复杂的变体添加额外的链接,允许有效地插入或删除任意元素引用。链表的一个缺点是访问时间是线性的(而且难以管道化)。
8+
9+
更快的访问,如随机访问,是不可行的。与链表相比,数组具有更好的缓存位置。
10+
11+
![Linked List](https://upload.wikimedia.org/wikipedia/commons/6/6d/Singly-linked-list.svg)
12+
13+
## 基本操作的伪代码
14+
15+
### 插入
16+
17+
```text
18+
Add(value)
19+
Pre: value is the value to add to the list
20+
Post: value has been placed at the tail of the list
21+
n ← node(value)
22+
if head = ø
23+
head ← n
24+
tail ← n
25+
else
26+
tail.next ← n
27+
tail ← n
28+
end if
29+
end Add
30+
```
31+
32+
```
33+
Prepend(value)
34+
Pre: value is the value to add to the list
35+
Post: value has been placed at the head of the list
36+
n ← node(value)
37+
n.next ← head
38+
head ← n
39+
if tail = ø
40+
tail ← n
41+
end
42+
end Prepend
43+
```
44+
45+
### 搜索
46+
47+
```text
48+
Contains(head, value)
49+
Pre: head is the head node in the list
50+
value is the value to search for
51+
Post: the item is either in the linked list, true; otherwise false
52+
n ← head
53+
while n != ø and n.value != value
54+
n ← n.next
55+
end while
56+
if n = ø
57+
return false
58+
end if
59+
return true
60+
end Contains
61+
```
62+
63+
### 删除
64+
65+
```text
66+
Remove(head, value)
67+
Pre: head is the head node in the list
68+
value is the value to remove from the list
69+
Post: value is removed from the list, true, otherwise false
70+
if head = ø
71+
return false
72+
end if
73+
n ← head
74+
if n.value = value
75+
if head = tail
76+
head ← ø
77+
tail ← ø
78+
else
79+
head ← head.next
80+
end if
81+
return true
82+
end if
83+
while n.next != ø and n.next.value != value
84+
n ← n.next
85+
end while
86+
if n.next != ø
87+
if n.next = tail
88+
tail ← n
89+
end if
90+
n.next ← n.next.next
91+
return true
92+
end if
93+
return false
94+
end Remove
95+
```
96+
97+
### 遍历
98+
99+
```text
100+
Traverse(head)
101+
Pre: head is the head node in the list
102+
Post: the items in the list have been traversed
103+
n ← head
104+
while n != ø
105+
yield n.value
106+
n ← n.next
107+
end while
108+
end Traverse
109+
```
110+
111+
### 反向遍历
112+
113+
```text
114+
ReverseTraversal(head, tail)
115+
Pre: head and tail belong to the same list
116+
Post: the items in the list have been traversed in reverse order
117+
if tail != ø
118+
curr ← tail
119+
while curr != head
120+
prev ← head
121+
while prev.next != curr
122+
prev ← prev.next
123+
end while
124+
yield curr.value
125+
curr ← prev
126+
end while
127+
yield curr.value
128+
end if
129+
end ReverseTraversal
130+
```
131+
132+
## 复杂度
133+
134+
### 时间复杂度
135+
136+
| Access | Search | Insertion | Deletion |
137+
| :-------: | :-------: | :-------: | :-------: |
138+
| O(n) | O(n) | O(1) | O(1) |
139+
140+
### 空间复杂度
141+
142+
O(n)
143+
144+
## 参考
145+
146+
- [Wikipedia](https://en.wikipedia.org/wiki/Linked_list)
147+
- [YouTube](https://www.youtube.com/watch?v=njTh_OwMljA&index=2&t=1s&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 优先队列
2+
3+
在计算机科学中, **优先级队列(priority queue)** 是一种抽象数据类型, 它类似于常规的队列或栈, 但每个元素都有与之关联的“优先级”。
4+
5+
在优先队列中, 低优先级的元素之前前面应该是高优先级的元素。 如果两个元素具有相同的优先级, 则根据它们在队列中的顺序是它们的出现顺序即可。
6+
7+
优先队列虽通常用堆来实现,但它在概念上与堆不同。优先队列是一个抽象概念,就像“列表”或“图”这样的抽象概念一样;
8+
9+
正如列表可以用链表或数组实现一样,优先队列可以用堆或各种其他方法实现,例如无序数组。
10+
11+
12+
## 参考
13+
14+
- [Wikipedia](https://en.wikipedia.org/wiki/Priority_queue)
15+
- [YouTube](https://www.youtube.com/watch?v=wptevk0bshY&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8&index=6)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 队列
2+
3+
在计算机科学中, 一个 **队列(queue)** 是一种特殊类型的抽象数据类型或集合。集合中的实体按顺序保存。
4+
5+
队列基本操作有两种:入队和出队。从队列的后端位置添加实体,称为入队;从队列的前端位置移除实体,称为出队。
6+
7+
8+
队列中元素先进先出 FIFO (first in, first out)的示意
9+
10+
![Queue](https://upload.wikimedia.org/wikipedia/commons/5/52/Data_Queue.svg)
11+
12+
## 参考
13+
14+
- [Wikipedia](https://en.wikipedia.org/wiki/Queue_(abstract_data_type))
15+
- [YouTube](https://www.youtube.com/watch?v=wjI1WNcIntg&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8&index=3&)

0 commit comments

Comments
 (0)