Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
joebiden
interview
提交
3ea32845
I
interview
项目概览
joebiden
/
interview
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
interview
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3ea32845
编写于
3月 10, 2018
作者:
辉哈
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加二分查找(折半查找)、TCP状态码
上级
f36e69d2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
9 deletion
+64
-9
.vscode/settings.json
.vscode/settings.json
+6
-1
Algorithm/BinarySearch.h
Algorithm/BinarySearch.h
+37
-0
README.md
README.md
+21
-8
未找到文件。
.vscode/settings.json
浏览文件 @
3ea32845
...
...
@@ -6,6 +6,11 @@
"xtree"
:
"cpp"
,
"xutility"
:
"cpp"
,
"iosfwd"
:
"cpp"
,
"vector"
:
"cpp"
"vector"
:
"cpp"
,
"algorithm"
:
"cpp"
,
"streambuf"
:
"cpp"
,
"tuple"
:
"cpp"
,
"system_error"
:
"cpp"
,
"xtr1common"
:
"cpp"
}
}
\ No newline at end of file
Algorithm/BinarySearch.h
0 → 100644
浏览文件 @
3ea32845
// 二分查找(折半查找):对于已排序,若无序,需要先排序
// 非递归
int
BinarySearch
(
vector
<
int
>
v
,
int
value
)
{
if
(
v
.
size
()
<=
0
)
return
-
1
;
int
low
=
0
;
int
high
=
v
.
size
()
-
1
;
while
(
low
<=
high
)
{
int
mid
=
low
+
(
high
-
low
)
/
2
;
if
(
v
[
mid
]
==
value
)
return
mid
;
else
if
(
v
[
mid
]
>
value
)
high
=
mid
-
1
;
else
low
=
mid
+
1
;
}
return
-
1
;
}
// 递归
int
BinarySearch2
(
vector
<
int
>
v
,
int
value
,
int
low
,
int
high
)
{
if
(
low
>
high
)
return
-
1
;
int
mid
=
low
+
(
high
-
low
)
/
2
;
if
(
v
[
mid
]
==
value
)
return
mid
;
else
if
(
v
[
mid
]
>
value
)
return
BinarySearch2
(
v
,
value
,
low
,
mid
-
1
);
else
return
BinarySearch2
(
v
,
value
,
mid
+
1
,
high
);
}
\ No newline at end of file
README.md
浏览文件 @
3ea32845
...
...
@@ -977,17 +977,22 @@ typedef struct BiTNode
### 排序
*
[
冒泡排序
](
Algorithm/BubbleSort.h
)
*
[
冒泡排序(改进版)
](
Algorithm/BubbleSort_orderly.h
)
*
[
选择排序
](
Algorithm/SelectionSort.h
)
*
[
快速排序
](
Algorithm/QuickSort.h
)
*
[
文件排序
](
Algorithm/FileSort
)
排序算法 | 平均时间复杂度 | 最差时间复杂度 | 空间复杂度 | 稳定性
---|---|---|---|---
[
冒泡排序
](
Algorithm/BubbleSort.h
)
| O(n
<sup>
2
</sup>
)|O(n
<sup>
2
</sup>
)|O(1)|稳定
[
冒泡排序(改进版)
](
Algorithm/BubbleSort_orderly.h
)
| O(n
<sup>
2
</sup>
)|O(n
<sup>
2
</sup>
)|O(1)|稳定
[
选择排序
](
Algorithm/SelectionSort.h
)
| O(n
<sup>
2
</sup>
)|O(n
<sup>
2
</sup>
)|O(1)|稳定
[
快速排序
](
Algorithm/QuickSort.h
)
| O(n
*
log
<sub>
2
</sub>
n) | O(n
<sup>
2
</sup>
) | O(log
<sub>
2
</sub>
n)~O(n) | 不稳定
[
文件排序
](
Algorithm/FileSort
)
|
### 查找
*
[
顺序查找
](
Algorithm/SequentialSearch.h
)
*
[
蛮力字符串匹配
](
Algorithm/BruteForceStringMatch.h
)
*
[
文件查找
](
Algorithm/FileSearch
)
查找算法 | 平均时间复杂度 | 空间复杂度 | 查找条件
---|---|---|---
[
顺序查找
](
Algorithm/SequentialSearch.h
)
| O(n) | O(1) | 无序或有序
[
二分查找(折半查找)
](
Algorithm/BinarySearch.h
)
| O(log
<sub>
2
</sub>
n)| O(1) | 有序
[
蛮力字符串匹配
](
Algorithm/BruteForceStringMatch.h
)
| O(n
*
m) |
[
文件查找
](
Algorithm/FileSearch
)
|
## Problems
...
...
@@ -1163,6 +1168,14 @@ TCP 首部
![
TCP首部
](
images/TCP首部.png
)
TCP:状态控制码(Code,Control Flag),占6比特,含义如下:
*
URG:紧急比特(urgent),当URG=1时,表明紧急指针字段有效,代表该封包为紧急封包。它告诉系统此报文段中有紧急数据,应尽快传送(相当于高优先级的数据), 且上图中的 Urgent Pointer 字段也会被启用。
*
ACK: 确认比特(Acknowledge)。只有当ACK=1时确认号字段才有效,代表这个封包为确认封包。当ACK=0时,确认号无效。
*
PSH: (Push function)若为1时,代表要求对方立即传送缓冲区内的其他对应封包,而无需等缓冲满了才送。
*
RST: 复位比特(Reset),当RST=1时,表明TCP连接中出现严重差错(如由于主机崩溃或其他原因),必须释放连接,然后再重新建立运输连接。
*
SYN: 同步比特(Synchronous),SYN置为1,就表示这是一个连接请求或连接接受报文,通常带有 SYN 标志的封包表示『主动』要连接到对方的意思。
*
FIN: 终止比特(Final),用来释放一个连接。当FIN=1时,表明此报文段的发送端的数据已发送完毕,并要求释放运输连接。
#### UDP
*
UDP(User Datagram Protocol,用户数据报协议)是OSI(Open System Interconnection 开放式系统互联) 参考模型中一种无连接的传输层协议,提供面向事务的简单不可靠信息传送服务,其传输的单位是用户数据报。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录