Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
CoderViking
notes
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
notes
/
Algorithm
/
入门.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
52 lines (39 loc) · 885 Bytes
master
Breadcrumbs
notes
/
Algorithm
/
入门.java
Copy path
Top
File metadata and controls
Code
Blame
52 lines (39 loc) · 885 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#
线性结构
*
数组
*
栈
*
链表
*
队列
*
哈希表
#
树结构
*
二叉树
*
二分搜索树
*
AVL
*
红黑树
*
Treap
*
Splay
*
堆
*
Trie
(
前缀树
)
*
线段树
*
K
-
D树
*
并查集
*
哈夫曼树
#
图结构
*
邻接矩阵
*
邻接表
#
时间复杂度
O
(
1
)
*
运行一次就找到了
(
最优的算法
)
O
(
n
)
*
数据有多长就需要运行多少次
*
数据量增大几倍
,
耗时也增大几倍
,
比如常见的遍历算法
O
(
n
^
2
)
*
就代表数据量增大n倍时
,
耗时增大n的平方倍
,
这是比线性更高的时间复杂度
*
比如冒泡排序
,
就是典型的O
(
n
^
2
)
的算法
,
对n个数排序
,
需要扫描n
×
n次
O
(
logn
)
*
数据增大n倍时
,
耗时增大logn倍
(
这里的log是以2为底的
)
*
比如
,
当数据增大256倍时
,
耗时只增大8倍
,
是比线性还要低的时间复杂度
*
二分查找就是O
(
logn
)
的算法
,
每找一次排除一半的可能
,
256
个数据中查找只要找8次就可以找到目标
O
(
nlogn
)
*
就是n
乘以logn
*
当数据增大256倍时
,
耗时增大
256
*
8
=
2048
倍
*
这个复杂度高于线性低于平方
,
归并排序就是O
(
nlogn
)
的时间复杂度
You can’t perform that action at this time.