알고리즘
문제를 해결하기위한 일련의 절차를 공식화한 형태로 표현한 것.
필요한 개념들
시간 복잡도
자료구조
단순구조: 정수/실수/문자/문자열
선형구조: 자주 출제
순차리스트/스택/큐/덱
연결리스트=> 단순연결리스트/이중연결리스트/원형연결리스트
비선형구조: 자주 출제
트리 => 일반트리/이진트리
그래프 => 방향 그래프/무방향 그래프
정렬
알고리즘 종류
Searching Algorithms
- used to find or retrieve an element from a data structure, or to determine its existence and location in the dataset. We discuss linear search and binary search.
like 숫자마추기 게임
[1,2,3,4 ~ 25 ~ 99,100]

const visited = []
visited = [1,2,3,4,5]
O(V + E)
V = vertices or nodes
E = edges or branches

const visited = []
const neighbours = []
phase 1
visitied = [1]
neighbours = [2,5]
phase 2
visited = [1,2]
neighbours = [5,3,4]
phase 3
visited = [1,2,5]
neighbours = [3,4]
.
.
.
result
visitied = [1,2,5,3,4]
O(V + E)
V = vertices or nodes
E = edges or branches
Sorting Algorithms
- used to rearrange elements in a list or an array in a certain order. We discuss bubble sort, insertion sort, and merge sort.
Array List Smaller & Sorted
Insertion : O(n)
Merge : O(n log(n))
Array List Larger & Unsorted
Insertion : O(n^2)
Merge : O(n log(n))
const source = [3,5,2,4,8,7,1,6]
const smallerThanMedian = [1,2,3]
const medianValue = [4] // pivot
const biggerThanMedian = [5,6,7,8]
## Prepare
try to select number close to the median.
4 is median value here.
Once we've selected that number, we move it to the end of the list
const source = [3,5,2,8,7,1,4]
Now we place a pointer at the left-most element, and the right-most element.
Pointer on index 0 = [value: 3]
pointer on index 6 = [value: 1] here is 6 out of 0 ~ 7
const source = [**3**,5,2,8,7,**1**,4]
phase 1
compare index 0 value and index 6 value.
if
the left-most value (here 3) is bigger than pivot(here 4)
and
the right-most value (here 6) is smaller than pivot(here 4)
swap both
Best case : O(n log(n))
Worst case : O((n^2))
Bubble Sort 느리지만 알아두자.
Graph Algorithms
- used to solve problems related to graph theory, where data is represented as a collection of nodes (or vertices) connected by edges. You probably know these as trees. We discuss depth-first search (dfs), breadth-first search (bfs), Dijkstra's algorithm, and A* algorithm.
Greedy
Not used for efficiency!
Brute-Force
divide & conquer 분할정복
Greedy
Queue