알고리듬,algorithm


1. Links, Also in 자료구조,data_structure

VisuAlgo - visualising data structures and algorithms through animation
https://visualgo.net

사실 이건 자료구조,data_structure or abstract_data_type과 밀접한데 어떤 관계인지 tbw

2. 알고리즘 분석





복잡도
{
복잡도: algorithm을 실행에 옮길 때 드는 비용,cost.
컴퓨터,computer가 algorithm을 실행,execution하여 답을 낼 때까지 드는 비용(시간이나 메모리의 양). (이광근)
}




주로 시간복잡도를 더 중요하게 여김.

P
NP
NP-완전,NP-completeness
NP-난해,NP-hard

}
O-표기법,O-notation
{
$g(n)$$f(n)$ 의 상위 한계이면,
$\forall c,\,\exists n_0$ such that
$n\ge n_0,\; f(n)\le c\cdot g(n)$



규칙
상수항은 O(1)로 표현
O(c)=O(1)
계수는 생략
O(cn)=cO(n)=O(n)
etc.


반복:
g(n)이 f(n)의 상위 한계이면,
c, ∃n0 such that
nn0, f(n) ≤ c·g(n)



(정의) 빅오(Big-oh):
모든 $n,\,n\ge n_0$ 에 대해 $f(n)\le cg(n)$ 인 조건을 만족하는 두 양의 상수 $c$$n_0$ 가 존재하기만 하면 $f(n)=O(g(n))$ 이다.

(C로 쓴 자료구조론, Fundamentals of Data Structures in C, 2e, p. 37)

}


3. 알고리듬의 전략



chk { 모든 가능성을 체크? 장점: 단순함. 단점: suboptimal. 자원낭비. 보통 시간복잡도,time_complexity의 벽에 부딪치는 경우가 많은듯? 그래서 사실상 이 방법을 쓸 수 없는 문제가 대부분. }
https://everything2.com/title/brute force

greedy_algorithm
{
전체 문제,problem를 생각하지 않고, 현재 상황에서 가능한 최고의 답 만을 찾는?
국소적 최적(local optimum)에는 쉽게 도달, 다만 global optimum에 도달하지 못할 가능성이 큼?

대표적인 예로는 Prim algorithm, Kruskal algorithm, Dijkstra algorithm 등
CHK
}

분할정복,divide_and_conquer
동적계획법,dynamic_programming,DP 다이내믹 프로그래밍, 동적 프로그래밍, 동적 계획법
{
이건 '동적-'을 페이지명으로 하지 않는게...
기억하며 풀기 (SNU이광근)

// from 석준희강의
Break up a problem into a series of overlapping subproblems, and build up solutions to larger and larger subproblems.
DP is a method of solving complex problems by breaking them down into subproblems that can be solved by working backwards from the last stage.
따라서 last stage에 smallest subproblem이 있다.

Steps to DP
  • Every problem is divided into stages(decision epochs)
  • Each stage requires a decision (action)
  • The decison at one stage transforms one state into a state in the next stage
  • The solution procedure is to find an optimal solution for every possible state(decision rule) at each stage(policy)
    • State- and action(decision)-dependent rewards or costs exist
  • There exists a recursive relationship(see 재귀,recursion) that identifies the optimal decision for stage $j$ , given that stage $j+1$ has already been solved
    • This solution procedure often starts at the last stage and works its way backward and the final stage must be solvable by itself
    • Given the current state, the optimal decision for each of the remaining states does not depend on the previous states or decisions

Richard Bellman이 처음 명명.
시간에 따라 순차적으로 최선의 결정을 내리는 데 필요한 문제 해결법으로 제시한 알고리듬.
순차적으로 의사결정을 통해 문제를 해결하는 최적화 기법 중 하나.
dynamic은 '시간에 따른 순차적 결정'을, programming은 계획(의사결정)을 의미.

(석준희 데이터학습과지능 강의 9 1)

분할정복,divide_and_conquer과? CHK
d&c 분할된 부분문제가 독립적 해를 합침
dp 분할된 부분문제가 겹침 해를 재사용
[https]여기에 따르면 대략 이런 듯 한데, CHK.

mklink
메모이제이션,memoization


잘 지은 이름은 아님. Divide and conquer같은 경우는 뭔지 바로 감이 오는데 이건 전혀 그렇지 않다.



Videos en
MIT OCW 6.006 Introduction to Algorithms, Fall 2011 ... 19. Dynamic Programming
https://www.youtube.com/watch?v=OQ5jsbhAv_M


3.1. 알고리즘의 패턴 (2021-07-1)

문제,problem 풀기 패턴,pattern
  • 모조리 훑기 exhaustive search
    : 비용이 크다는 단점
  • 되돌아가기 backtracking
  • 나눠풀어 합치기 divide-and-conquer
    : 문제를 작은 크기로 쪼개고, 쪼개진 부분을 풀고, 푼 결과들을 합쳐 전체 문제의 답으로 만듦
  • 기억하며 풀기 dynamic programming dynamic_programming
    문제의 일부분에 대해서 풀어가고, 그 결과를 기억.
    문제의 다른 부분을 풀 때 기억한 부분 답을 활용할 수 있으면 활용.
    예를 들어 점화식,recurrence_relation으로 답이 만들어지는 경우 부분 결과를 기억하면 반복계산을 줄일 수 있음. 피보나치_수열,Fibonacci_sequence 등.
  • 질러놓고 다듬기 iterative improvement
    한 개의 답 후보를 임의로 선택. 답이 아니면 일부분을 손질하면서 다듬어감. 답이 될 때까지.
// SNU이광근 컴여세 p124-126

4. 주제에 따른 알고리듬 분류

4.1. 탐색,검색,search

선형_탐색,linear_search

4.2. traversal

보통 순회,traversal로 번역
(바로 위) search와 차이는?


4.3. shortest path?

최단경로
최단거리 .... = 최단경로의 거리? 항상?
최소거리(이 용어는 해밍_코드,Hamming_code 그쪽 뉘앙스)

4.5. ...(delme)

위 세개는 경로,path 거리,distance 회로,circuit 등 관련.

4.6. 정렬,sort

sorting algorithms



Topics:
key
비교,comparison
안정성,stability

분류 CHK
실행 방법에 따라:
비교식 정렬(comparative sort)-한번에 키 값을 두개씩 비교하여 교환
분산식 정렬(distribute sort)-부분집합으로 분해/분할,partition 하고 각 부분 집합을 정렬 (하고 합침?)
정렬 장소에 따라
내부 정렬(internal sort) - 자료가 모두 메인 메모리에 있음
외부 정렬(external sort) - 보조 기억장치 사용

여러 PL의 정렬알고리듬 구현 모음
http://rosettacode.org/wiki/Category:Sorting_Algorithms

정렬 알고리듬에서 나타나는 패턴 시각화
https://wtracy.gitlab.io/sortraits/


4.7. memory_management

쓰레기_수집,garbage_collection
https://wiki.osdev.org/Category:Memory_management

5. 참조 - 구현


5.1. JavaScript

6.


6.1. Introduction to Algorithms 3e (2009)

aka CLR, CLRS

[ISBN-0262033844]


6.2. Introduction to Algorithms 4e (2022)

[ISBN-026204630X]

6.3. Algorithms 4e (2011)

Robert Sedgewick, Kevin Wayne
[ISBN-032157351X]

6.4. Mastering Algorithms with C (1999)

[ISBN-1565924533]

번역판: C로 구현한 알고리즘

6.5. TAOCP

Donald Knuth
[ISBN-0137935102]

6.6. The Algorithm Design Manual 2e (2008)

[ISBN-1849967202]

6.7. The Algorithm Design Manual 3e (2020)

Steven Skiena
[ISBN-3030542556]

7. MKLINK

문제,problem
problem_solving 과 closely related.

8. tmp bmks ko

Libre:알고리즘 ... 2022-08-30 현재 twin에 두기엔 내용이 상당히 부족
Libre:알고리즘_온라인_저지

9. tmp bmks en

Algorithms for Competitive Programming
https://cp-algorithms.com/
어떤 러시아어 사이트 번역, competitive_programming 리소스.