open-courses
Search…
公开课笔记
CMU 15-445/645 Database Systems
Relational Data Model
Advanced SQL
Database Storage
Buffer Pools
Hash Tables
Tree Indexes
Index Concurrency Control
Query Processing
Sorting&Aggregations
Join Algorithms
Query Optimization
Parallel Execution
Embedded Database Logic
Concurrency Control Theory
Two Phase Locking
Timestamp Ordering Concurrency Control
Multi-Version Concurrency Control
Logging Schemes
Database Recovery
Introduction to Distributed Databases
Distributed OLTP Databases
Distributed OLAP Databases
UCB - CS162
OS intro
Introduction to the Process
Processes, Fork, I/O, Files
I/O Continued, Sockets, Networking
Concurrency: Processes & Threads
Cooperating Threads, Synchronization
Semaphores, Condition Variables, Readers/Writers
Scheduling
Resource Contention & Deadlock
Address Translation, Caching
File System (18,19,20)
Distributed Systems, Networking, TCP/IP, RPC (21,22)
Distributed Storage, Key-Value Stores, Security (23)
Security & Cloud Computing (24)
Topic: Ensuring Data Reaches Disk
MIT - 6.006
Sequence and Set Interface
Data Structure for Dynamic Sequence Interface
Computation Complexity
Algorithms and Computation
Structure Of Computation
Graph & Search
Tree & Search
Weighted Shortest Paths
String Matching, Karp-Rabin
Priority Queue Interface & Implementation
Dictionary Problem & Implementation
Sorting
Dynamic Programming
Backtracking
Self-Balancing Tree
MIT - 6.824
2PC & 3PC
Introduction and MapReduce
RPC and Threads
Primary/Backup Replication
Lab: Primary/Backup Key/Value Service
Google File System (GFS)
Raft
Lab: Raft - Leader Election
Lab: Raft - Log Replication
Stanford-CS107
原始数据类型及相互转化
指鹿为马
泛型函数
泛型栈
运行时内存结构
从 C 到汇编
函数的活动记录
C 与 C++ 代码生成
编译的预处理过程
编译的链接过程
函数的活动记录续、并发
从顺序到并发和并行
信号量与多线程 1
信号量与多线程 2
复杂多线程问题
函数式编程 - Scheme 1
函数式编程 - Scheme 2
函数式编程 - Scheme 3
函数式编程 - Scheme 4
函数式编程 - Scheme 5
Python 基础
MIT - 6.001 - SICP
什么是程序
程序抽象
替代模型
时间/空间复杂度
数据抽象
高阶函数
Symbol
数据驱动编程与防御式编程
数据抽象中的效率与可读性
数据修改
环境模型
面向对象-消息传递
面向对象 - Scheme 实现
构建 Scheme 解释器
Eval-Apply Loop
Normal Order (Lazy) Evaluation
通用机
寄存器机器
子程序、栈与递归
在寄存器机器中执行
内存管理
MIT - 6.046
Randomized Algorithms
Skip Lists
System Design
Twitter
Cache Consistency & Coherence
DDIA 笔记
Replication
Transactions
The Trouble with Distributed Systems
Consistency & Consensus
Papers We Love
Consistent Hashing and Random Trees (1997)
Dynamic Hash Tables (1988)
LFU Implementation With O(1) Complexity (2010)
Time, Clocks, and the Ordering of Events in a Distributed System (1978)
Dapper, a Large-Scale Distributed Systems Tracing Infrastructure (2010)
Gorilla: A Fast, Scalable, In-Memory Time Series Database (2015)
Release It 笔记
Anti-patterns & Patterns in Microservice Architecture
Database Design
Log Structured Merge (LSM) Tree & Usages in KV Stores
Prometheus
Powered By
GitBook
Computation Complexity
Computation Difficulty: P, EXP, R
P = {problems solvable in polynomial time}
EXP = {problems solvable in exponential time}
R = {problems solvable in finite time}
这里,polynomial time 指
O
(
n
c
)
O(n^c)
O
(
n
c
)
,exponential time 指
O
(
2
n
c
)
O(2^{n^c})
O
(
2
n
c
)
,其中 c 为常数。
它们之间的关系如图 1 所示:
图 1 - Computation Complexity
P, NP, NP-Hard, NP-Complete
P 问题
许多问题都属于 P,如我们耳熟能详的排序算法、最短路径算法等。
NP 问题
在理解 NP 问题之前,需要引入一个概念:Decision Problems。它是指答案为是或否的问题,它的解决方案通常由一个个小决定串联而成。如俄罗斯方块(Tetris),每一种方案都由无数个小形状如何放置的决定串联而成。我们可以将所有问题都抽象成这种形式,于是可以通过两种角度来理解 NP 问题的定义:
1.
假如在解决一个问题的每一个决定中,我们都能够幸运地猜中最佳选项,这个问题能在 polynomial 的时间内被解决。
2.
虽然我们无法找到一个确定的方案能在 polynomial 的时间内解决该问题,但我们确定能在 polynomial 的时间内检查一个方案是否正确。
NP 问题举例:
俄罗斯方块
P 与 NP
在计算复杂度理论领域,有一个推论:
P
≠
N
P
P \neq NP
P
=
NP
它的引申含义可以有:
1.
我们无法把运气编写到程序中
2.
找到一个解决方案比验证一个解决方案难
这个推论至今未被证明。因此图 1 中,NP 与 P 之间的空白是否真的存在,还未有定论。
NP-Hard
NP-Hard 问题指的是难度大于或等于所有 NP 问题的问题。如 EXP、R 问题等。
NP-Complete
N
P
C
o
m
p
l
e
t
e
=
N
P
∩
N
P
H
a
r
d
NPComplete = NP \cap NPHard
NPC
o
m
pl
e
t
e
=
NP
∩
NP
H
a
r
d
NP-Complete 问题位于 NP 与 NP-Hard 的交集点上。
NP-Complete 问题举例:
Knapsack
3-Partition: given n integers, can you divide them into triples of equal sum?
Traveling Salesman Problem
Longest Common Sbusequence of K Strings
Minesweeper, Sudoku & most puzzles
SAT: given a Boolean formula (and, or, not), is it ever true?
shortest paths in 3D
3-coloring a given graph
find largest clique in a given graph
EXP/EXP-Hard/EXP-Complete
与 NP/NP-Hard/NP-Complete 之间的关系类似。Chess 是一个 EXP-Complete 问题。
Uncomputable Problem
Halting Problem
输入任意一个计算机程序,它运行一段时间后会停顿吗?
目前没有任何算法能够在有限时间内解决该问题,因此它不在 R 的范围内。
Most Decision Problems Are Uncomputable
尽管在计算机理论与实践过程中,我们遇到的大部分问题都是在有限时间内可以解决的,但实际上大部分 Decision Problems 都无法在有限时间内解决。
证明
Decision Problem 可以被抽象成寻找这样一个函数:输入是某个字符串(二进制序列),即问题描述;输出为是或否,即问题的答案。而这个字符串可以是任意字符串,因此它可以被进一步抽象成一个实数。
Program 被转换成机器码以后就是一段有限长度的二进制序列,因此它可以被进一步抽象成一个整数。
由于实数的数量远远多于整数,因此大部分 Decision Problems 都无法在有限时间内计算得到结果。
证明完毕
Reductions
将新问题转化成熟悉的问题的技术。举例如下:
unweighted shortest path => weighted (set weights = 1)
min-product path => shortest path (take logs)
longest path => shortest path (negate weights)
shortest ordered tour => shortest path (k copies of the graph)
cheapest leaky-tank path => shortest path (graph reduction)
Reduction 又分为 One-call reductions 和 Multi-call reductions,主要区别在于将新问题转化为一个还是多个熟悉的问题。
所有的 NP-Complete 问题都可以互相转化,因此它们的难度一样。所有 NP-Complete 问题的共同祖先是 3-Partition 问题。
参考:
6.006 course notes
MIT - 6.006 - Previous
Data Structure for Dynamic Sequence Interface
Next - MIT - 6.006
Algorithms and Computation
Last modified
3yr ago
Copy link
Outline
Computation Difficulty: P, EXP, R
P, NP, NP-Hard, NP-Complete
P 问题
NP 问题
EXP/EXP-Hard/EXP-Complete
Uncomputable Problem
Halting Problem
Most Decision Problems Are Uncomputable
Reductions
参考: