๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ 132

[Next.js] CSR(client side render) vs SSR(server side render)

* Rendering : js code๋ฅผ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋Š” html๋กœ ๋ฐ”๊พธ๋Š” ๊ฒƒ - React render : CSR (client side rendering) create-react-app ์„ ์‚ฌ์šฉํ•ด react๋งŒ์œผ๋กœ application์„ ์ƒ์„ฑํ•˜๋ฉด , client side rendering client side rendering => ์‚ฌ์šฉ์ž ๋ธŒ๋ผ์šฐ์ €์ธ client๋‹จ์—์„œ rendering ์ž‘์—…์„ ํ•œ๋‹ค. ๋‹จ์  ํŽ˜์ด์ง€์˜ ์‹ค์ œ ์†Œ์Šค์ฝ”๋“œ๋Š” ๋น„์–ด์žˆ๋‹ค. ex. = UI๊ฐ€ ์—†๋‹ค ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ๋ชจ๋“  JS ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ , ์‹คํ–‰ํ•œ ํ›„์—์•ผ ํ™”๋ฉด์— ๋ณด์—ฌ์ง€๋Š” ๊ฒƒ ์ƒˆ๋กœ๊ณ ์นจ ์‹œ, JS์—”์ง„์ด ์œ„์˜ ์‚ฌํ•ญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์‹œ๊ฐ„ ๋™์•ˆ ๋นˆ ํ™”๋ฉด์ด ๋ณด์—ฌ์ง SEO, ๊ฒ€์ƒ‰ ์—”์ง„ ์ตœ์ ํ™” Search Engine Optimization Goo..

Next.js 2024.03.15

[Next.js] Next ํ”„๋กœ์ ํŠธ ์ˆ˜๋™ setup

1. ํ”„๋กœ์ ํŠธ ํด๋” ๋งŒ๋“ค๊ธฐ $ mkdir prj_folder 2. ํ”„๋กœ์ ํŠธ ํด๋”๋กœ ์ด๋™ $ cd prj_folder 3. ํ•ด๋‹น ํด๋”๋ฅผ VSCode์—์„œ ์—ด์–ด๋ณด๊ธฐ $ code . 4. package.json ํด๋” ์ƒ์„ฑ $ npm init -y 5. ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ - react : UI์™€ ๋‹ค๋ฅธ ๋ชจ๋“  ๊ฒƒ์„ ๊ตฌ์„ฑ - react-dom : ์œ„์˜ ๊ฒƒ์„ ๋ธŒ๋ผ์šฐ์ €์˜ Document Object Model(DOM)์— ๋ Œ๋”ํ•˜๋Š” ์—ญํ•  $ npm install react@latest next@latest react-dom@latest 6. jackage.json ์Šคํฌ๋ฆฝํŠธ ์ˆ˜์ • "scripts" : { "dev" : "next dev" }, 7. ํ”„๋กœ์ ํŠธ ์‹คํ–‰ ํ™•์ธ $ npm run dev - local server ์‹ค..

Next.js 2024.03.14

[React] Vite + React + TS ๊ฐœ๋ฐœ ์„œ๋ฒ„ ๊ตฌ์ถ•

Node.js ์„ค์น˜ Node.js Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. nodejs.org Node.js ์„ค์น˜ ํ™•์ธ node -v Vite : ๊ฐœ๋ฐœํ™˜๊ฒฝ ๊ตฌ์„ฑ Vite Vite, ์ฐจ์„ธ๋Œ€ ํ”„๋ŸฐํŠธ์—”๋“œ ๊ฐœ๋ฐœ ํˆด ko.vitejs.dev npm create vite@latest - Projet name - framework : React - variat : TypeScript + SWC ( SWC: Rust typescript ์ปดํŒŒ์ผ๋Ÿฌ) ๊ธฐ๋ณธ์„ค์ • ์ฃผ์ž… npm i - react, react dom, typescript, vite...etc (package.json) ์ •์ƒ ์ž‘๋™ ํ™•์ธ npm run dev git ์—ฐ๊ฒฐ git ..

React 2024.02.26

[Algorithm] ๊ทธ๋ž˜ํ”„ ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜ - ๋„ˆ๋น„ ์šฐ์„  ํƒ์ƒ‰ (Breadth-First Search)

๊ทธ๋ž˜ํ”„ ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋„ˆ๋น„ ์šฐ์„  ํƒ์ƒ‰ (BFS; Breadth First Search) ์ •์ ๋“ค๊ณผ ๊ฐ™์€ ๋ ˆ๋ฒจ์— ์žˆ๋Š” ๋…ธ๋“œ๋“ค(ํ˜•์ œ ๋…ธ๋“œ)์„ ๋จผ์ € ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ์‹ A - B - C - D - G - H - I - E - F - J ๊นŠ์ด ์šฐ์„  ํƒ์ƒ‰ (DFS; Depth First Search) ์ •์ ์˜ ์ž์‹๋“ค์„ ๋จผ์ € ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ์‹ A - B - D - E - F - C - G - H - I - J

[Algorithm] ์ˆœ์ฐจ ํƒ์ƒ‰ (Sequential Search)

์ˆœ์ฐจ ํƒ์ƒ‰ (Sequential Search) ? - ์—ฌ๋Ÿฌ ๋ฐ์ดํ„ฐ ์ค‘์—์„œ ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ฐพ์•„๋‚ด๋Š” ๊ฒƒ์„ ์˜๋ฏธ - ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ด๊ฒจ์žˆ๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ์•ž์—์„œ๋ถ€ํ„ฐ ํ•˜๋‚˜์”ฉ ๋น„๊ตํ•ด์„œ ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ฐพ๋Š” ๋ฐฉ๋ฒ• data = list() for num in range(10): data.append(randint(1, 100)) #random ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ def sequencial(data, search_data): for index in range(len(data)): if data[index] == search_data: return index return -1 sequencial(data, 4)

[Algorithm] ์ด์ง„ ํƒ์ƒ‰ (Binary Search)

์ด์ง„ ํƒ์ƒ‰ (Binary Search) ? ํƒ์ƒ‰ํ•  ์ž๋ฃŒ๋ฅผ ๋‘˜๋กœ ๋‚˜๋ˆ„์–ด ํ•ด๋‹น ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ์„๋งŒํ•œ ๊ณณ์„ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ• ๋ถ„ํ•  ์ •๋ณต ์•Œ๊ณ ๋ฆฌ์ฆ˜๊ณผ ์ด์ง„ ํƒ์ƒ‰ ๋ถ„ํ•  ์ •๋ณต ์•Œ๊ณ ๋ฆฌ์ฆ˜ (Divide and Conquer) Divide : ๋ฌธ์ œ๋ฅผ ํ•˜๋‚˜ ๋˜๋Š” ๋‘˜ ์ด์ƒ์œผ๋กœ ๋‚˜๋ˆˆ๋‹ค. Conquer : ๋‚˜๋ˆ ์ง„ ๋ฌธ์ œ๊ฐ€ ์ถฉ๋ถ„ํžˆ ์ž‘๊ณ , ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•˜๋ฉด ํ•ด๊ฒฐํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š๋‹ค๋ฉด ๋‹ค์‹œ ๋‚˜๋ˆˆ๋‹ค. ์ด์ง„ ํƒ์ƒ‰ Divide : ๋ฆฌ์ŠคํŠธ๋ฅผ ๋‘ ๊ฐœ์˜ ์„œ๋ธŒ ๋ฆฌ์ŠคํŠธ๋กœ ๋‚˜๋ˆˆ๋‹ค. Conquer ๊ฒ€์ƒ‰ํ•  ์ˆซ์ž(search) > ์ค‘๊ฐ„๊ฐ’ , ๋’ท ๋ถ€๋ถ„์˜ ์„œ๋ธŒ ๋ฆฌ์ŠคํŠธ์—์„œ ๊ฒ€์ƒ‰ํ•  ์ˆซ์ž๋ฅผ ์ฐพ๋Š”๋‹ค. ๊ฒ€์ƒ‰ํ•  ์ˆซ์ž(search) < ์ค‘๊ฐ„๊ฐ’ , ์•ž ๋ถ€๋ถ„์˜ ์„œ๋ธŒ ๋ฆฌ์ŠคํŠธ์—์„œ ๊ฒ€์ƒ‰ํ•  ์ˆซ์ž๋ฅผ ์ฐพ๋Š”๋‹ค. def binary_search(data, search): if len(data) == ..

[Algorithm] ๋ณ‘ํ•ฉ ์ •๋ ฌ(merge sort)

๋ณ‘ํ•ฉ ์ •๋ ฌ(merge sort) ? ์žฌ๊ท€ ์šฉ๋ฒ•์„ ํ™œ์šฉํ•œ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ ˆ๋ฐ˜์œผ๋กœ ์ž˜๋ผ ๋น„์Šทํ•œ ํฌ๊ธฐ์˜ ๋‘ ๋ถ€๋ถ„ ๋ฆฌ์ŠคํŠธ๋กœ ๋‚˜๋ˆ” ๊ฐ ๋ถ€๋ถ„ ๋ฆฌ์ŠคํŠธ๋ฅผ ์žฌ๊ท€์ ์œผ๋กœ ํ•ฉ๋ณ‘ ์ •๋ ฌ์„ ์ด์šฉํ•ด ์ •๋ ฌ ๋‘ ๋ถ€๋ถ„ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋‹ค์‹œ ํ•˜๋‚˜์˜ ์ •๋ ฌ๋œ ๋ฆฌ์ŠคํŠธ๋กœ ํ•ฉ๋ณ‘ def merge(left, right): merged = list() left_point, right_point = 0,0 #case1: left/right ๋‘˜๋‹ค ๋ฐ์ดํ„ฐ ์žˆ์„ ๋•Œ while len(left) > left_point and len(right) > right_point: it left[left_point] > right[right_point]: merged.append(right[right_point]) right_point += 1 else: merged...

[Algorithm] ํ€ต ์ •๋ ฌ(Quick Sort)

ํ€ต ์ •๋ ฌ(quick sort) ? ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ๊ฝƒ ๊ธฐ์ค€์ (pivot)์„ ์ •ํ•ด์„œ, ๊ธฐ์ค€์ ๋ณด๋‹ค ์ž‘์€ ๋ฐ์ดํ„ฐ๋Š” ์™ผ์ชฝ, ํฐ ๋ฐ์ดํ„ฐ๋Š” ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๋ชจ์œผ๋Š” ํ•จ์ˆ˜ ๊ฐ ์™ผ์ชฝ, ์˜ค๋ฅธ์ชฝ์€ ์žฌ๊ท€์šฉ๋ฒ•์„ ์‚ฌ์šฉํ•ด์„œ ๋‹ค์‹œ ๋™์ผ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•ด ์œ„ ์ž‘์—… ๋ฐ˜๋ณต ํ•จ์ˆ˜๋Š” ์™ผ์ชฝ(left) + ๊ธฐ์ค€์ (pivot) + ์˜ค๋ฅธ์ชฝ(right)์„ ๋ฆฌํ„ด def qsort(data): if len(data) data[index]: left.append(data[index]) else: right.append(data[index]) #2.list comprehension ์‚ฌ์šฉ left = [item for item in data[1:] if pivot > item] right = [item for item in data[1:] if pivot

๋™์  ๊ณ„ํš๋ฒ•( Dynamic Programming) ๊ณผ ๋ถ„ํ•  ์ •๋ณต(Divide Conquer)

๋™์  ๊ณ„ํš๋ฒ• ( DP; Dynamic Programming) ? ์ž…๋ ฅ ํฌ๊ธฐ๊ฐ€ ์ž‘์€ ๋ถ€๋ถ„ ๋ฌธ์ œ๋“ค์„ ํ•ด๊ฒฐํ•œ ํ›„, ํ•ด๋‹น ๋ถ€๋ถ„ ๋ฌธ์ œ์˜ ํ•ด๋ฅผ ํ™œ์šฉํ•ด ๋ณด๋‹ค ํฐ ํฌ๊ธฐ์˜ ๋ถ€๋ถ„ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐ ์ƒํ–ฅ์‹ ์ ‘๊ทผ๋ฒ• Memoization ๊ธฐ๋ฒ• : ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ์‹œ, ์ด์ „์— ๊ณ„์‚ฐํ•œ ๊ฐ’์„ ์ €์žฅํ•˜์—ฌ ๋‹ค์‹œ ๊ณ„์‚ฐํ•˜์ง€ ์•Š๋„๋ก ํ•จ -> ์‹คํ–‰์†๋„ ํ–ฅ์ƒ ๋ฌธ์ œ๋ฅผ ์ž˜๊ฒŒ ์ชผ๊ฐค ๋•Œ, ๋ถ€๋ถ„ ๋ฌธ์ œ๋Š” ์ค‘๋ณต๋˜์–ด ์žฌํ™œ์šฉ๋จ -> ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜์—ด ๋ถ„ํ•  ์ •๋ณต (Divide and Conquer ) ? ๋ฌธ์ œ๋ฅผ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์„ ๋•Œ๊นŒ์ง€ ๋‚˜๋ˆ„์–ด์„œ, ๊ฐ๊ฐ ํ’€๋ฉด์„œ ๋‹ค์‹œ ํ•ฉ๋ณ‘ํ•˜์—ฌ ๋ฌธ์ œ์˜ ๋‹ต์„ ์–ป๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ•˜ํ–ฅ์‹ ์ ‘๊ทผ๋ฒ• (์ผ๋ฐ˜์ ์œผ๋กœ ์žฌ๊ท€ํ•จ์ˆ˜๋กœ ๊ตฌํ˜„) ๋ฌธ์ œ๋ฅผ ์ž˜๊ฒŒ ์กฐ๊ฐค ๋•Œ, ๋ถ€๋ถ„ ๋ฌธ์ œ๋Š” ์„œ๋กœ ์ค‘๋ณต๋˜์ง€ ์•Š์Œ ๊ณตํ†ต์ ๊ณผ ์ฐจ์ด์  ๊ณตํ†ต์  : ๋ฌธ์ œ๋ฅผ ์ž˜๊ฒŒ ์ชผ๊ฐœ์„œ, ๊ฐ€์žฅ ์ž‘์€ ๋‹จ์œ„๋กœ ๋ถ„ํ•  ์ฐจ์ด์  ๋™..