본문 바로가기

전체 글195

32. Exploring Modules & The NPM Universe 323. Working With module.exports ./math.js module.exports = { add: (a, b) => a + b, PI: 3.14159 } ./app.js const { add, PI } = require('./math') console.log(add(2, 4)); console.log(PI); 324. Requiring A Directory When requiring a directory, index.js file will be used in Node 325. Introducing NPM NPM - Node Package Manager - A library of thousands of packages published by other developers that we.. 2022. 1. 28.
31. Our First Brush With Node 318. The Node REPL - REPL: Read-Eval-Print Loop 320 - 321. global - The global namespace object process - It provides information about, and control over, the current Node.js process. process.argv - Returns an array containing the command-line arguments passed when the Node.js process was launched. fs - It enables interacting with the file system in a way modeled on standard POSIX functions. con.. 2022. 1. 27.
Graph Depth-First Search (DFS) Backtracking 전에 가능한한 시작점으로부터 깊은 노드들을 먼저 탐색한다. 보통 재귀나 stack을 사용하여 구현. Breadth-First Search (BFS) 시작점으로부터 같은 깊이의 노드들을 먼저 탐색한 후 더 깊은 노드들을 탐색한다. queue를 사용하여 구현. Lowest Common Ancestor (LCA) 트리 구조에서 height가 가장 낮은 공통 ancestor을 LCA라 부른다. Euler tour를 순회하는 방법 - sqrt decomposition (O(n) for preprocessing, O(n^(1/2)) for query) - segment tree (O(n) for preprocessing, O(log n) for q.. 2022. 1. 25.
Merge / Quick Sort & Binary Search Merge sort Sorting 방법 중 하나. 배열을 반으로 쪼개어(divide), 더 이상 나눌 수 없을 때 다시 합치면서(conquer) 배열을 정렬한다. Complexity: O(n log n) 으로 안정적이다. Quick sort Sorting 방법 중 하나. 하나의 pivot을 잡아 왼쪽에 pivot보다 작은 수들을, 오른쪽에 pivot보다 큰 수들을 놓은 다음, 좌, 우로 나누어 다시 pivot을 잡고 위의 과정을 진행한다. Complexity: O(n log n), O(n^2) (worst case) Binary search 정렬되어 있는 배열에서 원하는 원소를 O(log n)만에 찾는 방법. int binary_search(int num[], int from, int to, int ta.. 2022. 1. 23.