小学数学中的竖式计算,就是一个算法,曾被用于设计乘法电路......小到Sorting或Searching,大到AI,算法统治着一切!
Algorithm is a procedure of
Finite Steps
to solve problem in an efficient way hopefully. Take algorithm as aTechnology
!
Sequence
,If...Else...
,Loop
, and (algorithmic)Recurrence
! Recurrence is essentially loop, but more powerful! Loop is for items. Recurrence is for subproblems!
Data structure
is used to hold and manipulate data! Using appropriate data structure is an important part of algorithm design. Sometimes, different data structure would cause different asymptotic performance of algorithm.
Facts
Proof of the Halting Problem
def halt(func, *args, **kwargs) -> bool:
""" Return True if func(args,kwargs) would stop, otherwist False. """
... # ??
def magic(*args, **kwargs):
while halt(magic,*args,**kwargs):
pass
For the Halting Problem and other unsolvable problems, there are proofs that no algorithm can exist that, for every input, eventually produces the correct answer. A procedure attempting to solve an unsolvable problem might always produce an answer but is sometimes incorrect, or all the answers it produces might be correct but for some inputs it never produces an answer. ---- 《CLRS》
Subproblems
Divide&Conquer
算法思路非常的自然和普遍,将大问题分解成Subproblem,逐个击破,而小问题的时间复杂度为通常是\(\Theta(1)\)。Dynamic Programming
!或者Subproblem之间存在一些可以被利用的关联,进一步提高算法性能。Greedy
有点特殊,有些问题在划分Subproblem后,可以直接做出最优选择,而不必等待Subproblem的计算结果。此时也可以使用Dynamic Programming,但性能不够好。-- 目录[6] --
-- 文章[20] --