๋ชฉ๋ก์ ์ฒด ๊ธ (1103)
KoreanFoodie's Study

Quick sort python code implementation ํต์ํธ(Quicksort)๋ฅผ ํ์ด์ฌ ์ฝ๋๋ก ๊ตฌํํด ๋ณด์. ํต ์ํธ(Quick sort) ํต ์ํธ๋ ๋ฐฐ์ด์ ํํฐ์ ์ ์ด์ฉํด์ ๋ฐ์ผ๋ก ๋๋๊ณ , ๋ค์ ์ด์ ๋ฐฐ์ด์ ๋ฐ์ผ๋ก ๋๋ ๋ฐฉ์์ ์ฌ๊ท์ ์ผ๋ก ์ ์ฉํ๋ค. ํํฐ์ ์ ์ผ๋ฐ์ ์ผ๋ก, ์ ์ผ ๋ ๋ฐฐ์ด์ ์์๋ฅผ pivot์ผ๋ก ์ก๊ณ , ํด๋น pivot๊ฐ๋ณด๋ค ์์ ๊ฐ์ ์ผ์ชฝ์ผ๋ก ๋ชฐ์ ๋ฃ๊ณ , ํฐ ๊ฐ์ ์ค๋ฅธ์ชฝ์ผ๋ก ๋ชฐ์๋ฃ๋๋ค. ์ด ๊ณผ์ ์ ์ฌ๊ท์ ์ผ๋ก ๋ฐ๋ณตํ๋ฉด, ๊ฐ ํํฐ์ ๋ง๋ค O(n) ํ์์ด ๊ฑธ๋ฆฌ๊ณ , ์ด ํํฐ์ ์ ํ๊ท ์ ์ผ๋ก O(logn) ํ์์ด ๊ฑธ๋ฆฌ๋ฏ๋ก, ์ด ์๊ฐ์ O(nlogn)์ด ๊ฑธ๋ฆฌ๋ ๊ฒ์ ์ ์ ์๋ค. ์ํคํผ๋์์ ์ค๋ช ์ ์ฐธ๊ณ ํด ๋ณด์. ํํฐ์ ์ ๋ค์๊ณผ ๊ฐ์ด ์๋ํ๋ค. ์๋ ์ฝ๋๋ฅผ ์ดํด๋ณด์. function par..

Merge sort python code implementation merge sort ํ์ด์ฌ ์ฝ๋๋ฅผ ์์ฑํด ๋ณด์. ๋ณํฉ ์ ๋ ฌ(Merge Sort) ์ํคํผ๋์์ ์ค๋ช ์ ์ฐธ๊ณ ํด ๋ณด์. ๋ณํฉ ์ ๋ ฌ์ ๋ค์๊ณผ ๊ฐ์ด ์๋ํ๋ค. ๋ฆฌ์คํธ์ ๊ธธ์ด๊ฐ 0 ๋๋ 1์ด๋ฉด ์ด๋ฏธ ์ ๋ ฌ๋ ๊ฒ์ผ๋ก ๋ณธ๋ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ์๋ ์ ๋ ฌ๋์ง ์์ ๋ฆฌ์คํธ๋ฅผ ์ ๋ฐ์ผ๋ก ์๋ผ ๋น์ทํ ํฌ๊ธฐ์ ๋ ๋ถ๋ถ ๋ฆฌ์คํธ๋ก ๋๋๋ค. ๊ฐ ๋ถ๋ถ ๋ฆฌ์คํธ๋ฅผ ์ฌ๊ท์ ์ผ๋ก ํฉ๋ณ ์ ๋ ฌ์ ์ด์ฉํด ์ ๋ ฌํ๋ค. ๋ ๋ถ๋ถ ๋ฆฌ์คํธ๋ฅผ ๋ค์ ํ๋์ ์ ๋ ฌ๋ ๋ฆฌ์คํธ๋ก ํฉ๋ณํ๋ค. ๋ณํฉ ์ ๋ ฌ์ ํต์ฌ์, ๋ฌธ์ ๋ฅผ ํธ๋ ๋ฐฉ๋ฒ๋ก ์ ์ฌ์ด์ฆ๋ฅผ ๋ฐ์ผ๋ก ์ชผ๊ฐ ๋ ์์ ์ ์ฉํด์ ์ ๋ ฌ์ ์๋ฃํ ํ, ์ ๋ ฌ์ด ์๋ฃ๋ ๋ฐ์ชฝ์ง๋ฆฌ 2๊ฐ๋ฅผ ๋ค์ ํฉ์นจ์ผ๋ก์จ ์ ๋ ฌ์ ๋ง์น๋ค๋ ๊ฒ์ด๋ค. ์ฆ, merge_sortํจ์๋ 2๊ฐ์ merge..

Bubble sort python code implementation. ๋ฒ๋ธ ์ ๋ ฌ์ ํ์ด์ฌ ์ฝ๋๋ก ๊ตฌํํด ๋ณด์. ๋ฒ๋ธ ์ ๋ ฌ (Bubble Sort) ์ํคํผ๋์์ ์ ์๋ฅผ ์ฐธ๊ณ ํด ๋ณด์. : ๊ฑฐํ ์ ๋ ฌ(Bubble sort)์ ๋ ์ธ์ ํ ์์๋ฅผ ๊ฒ์ฌํ์ฌ ์ ๋ ฌํ๋ ๋ฐฉ๋ฒ์ด๋ค. ์๊ฐ ๋ณต์ก๋๊ฐ O(n^2)์ผ๋ก ์๋นํ ๋๋ฆฌ์ง๋ง, ์ฝ๋๊ฐ ๋จ์ํ๊ธฐ ๋๋ฌธ์ ์์ฃผ ์ฌ์ฉ๋๋ค. ์์์ ์ด๋์ด ๊ฑฐํ์ด ์๋ฉด์ผ๋ก ์ฌ๋ผ์ค๋ ๋ฏํ ๋ชจ์ต์ ๋ณด์ด๊ธฐ ๋๋ฌธ์ ์ง์ด์ง ์ด๋ฆ์ด๋ค. ์์๋ฅผ ํตํด ๋ฒ๋ธ ์ ๋ ฌ์ด ์ด๋ป๊ฒ ๋์ํ๋์ง ์์๋ณด์. ๋ฒ๋ธ ์ ๋ ฌ์ ๋งค์ฐ ๋จ์ํ๋ฐ, ๊ทธ๋ฅ ์ฒ์๋ถํฐ 2๊ฐ์ฉ ์ง์ ์ง์ด ๊ฐ์ ๋น๊ตํ ํ, ์์ ๋ ์์ ์์ผ๋ก, ํฐ ๋ ์์ ๋ค๋ก ๋ณด๋ด๋ฉด ๋๋ค. (55, 07)์ (07, 55)๋ก, (55, 78)์ ๊ทธ๋๋ก, (78, 12)๋ (12..

Insertion sort python code implemetation ์ฝ์ ์ ๋ ฌ์ ํ์ด์ฌ ์ฝ๋๋ก ๊ตฌํํด ๋ณด์. ์ฝ์ ์ ๋ ฌ (Insertion sort) ์ํคํผ๋์์ ๋์จ ์ ์๋ฅผ ์ฐธ๊ณ ํด ๋ณด์. ์ ํ ์ ๋ ฌ(้ธๆๆดๅ, selection sort)์ ์ ์๋ฆฌ ์ ๋ ฌ ์๊ณ ๋ฆฌ์ฆ์ ํ๋๋ก, ๋ค์๊ณผ ๊ฐ์ ์์๋ก ์ด๋ฃจ์ด์ง๋ค. ์ฃผ์ด์ง ๋ฆฌ์คํธ ์ค์ ์ต์๊ฐ์ ์ฐพ๋๋ค. ๊ทธ ๊ฐ์ ๋งจ ์์ ์์นํ ๊ฐ๊ณผ ๊ต์ฒดํ๋ค(ํจ์ค(pass)). ๋งจ ์ฒ์ ์์น๋ฅผ ๋บ ๋๋จธ์ง ๋ฆฌ์คํธ๋ฅผ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ๊ต์ฒดํ๋ค. ๋น๊ตํ๋ ๊ฒ์ด ์์ ์๊ฐ์ ์ด๋ฃจ์ด์ง๋ค๋ ๊ฐ์ ์๋, n๊ฐ์ ์ฃผ์ด์ง ๋ฆฌ์คํธ๋ฅผ ์ด์ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ์ ๋ ฌํ๋ ๋ฐ์๋ Θ(n^2) ๋งํผ์ ์๊ฐ์ด ๊ฑธ๋ฆฐ๋ค. ์ ํ ์ ๋ ฌ์ ์๊ณ ๋ฆฌ์ฆ์ด ๋จ์ํ๋ฉฐ ์ฌ์ฉํ ์ ์๋ ๋ฉ๋ชจ๋ฆฌ๊ฐ ์ ํ์ ์ธ ๊ฒฝ์ฐ์ ์ฌ์ฉ์ ์ฑ๋ฅ ์์ ์ด์ ์ด..

selection sort python code ์ ํ์ ๋ ฌ์ ํ์ด์ฌ ์ฝ๋๋ก ๊ตฌํํด ๋ณด์. ์ ํ์ ๋ ฌ(Selection sort ๊ธฐ๋ณธ ์ค๋ช ) ์ํคํผ๋์์ ์๋ ์ ์๋ฅผ ์ฐธ๊ณ ํด ๋ณด์. ์ ํ ์ ๋ ฌ(้ธๆๆดๅ, selection sort)์ ์ ์๋ฆฌ ์ ๋ ฌ ์๊ณ ๋ฆฌ์ฆ์ ํ๋๋ก, ๋ค์๊ณผ ๊ฐ์ ์์๋ก ์ด๋ฃจ์ด์ง๋ค. ์ฃผ์ด์ง ๋ฆฌ์คํธ ์ค์ ์ต์๊ฐ์ ์ฐพ๋๋ค. ๊ทธ ๊ฐ์ ๋งจ ์์ ์์นํ ๊ฐ๊ณผ ๊ต์ฒดํ๋ค(ํจ์ค(pass)). ๋งจ ์ฒ์ ์์น๋ฅผ ๋บ ๋๋จธ์ง ๋ฆฌ์คํธ๋ฅผ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ๊ต์ฒดํ๋ค. ๋น๊ตํ๋ ๊ฒ์ด ์์ ์๊ฐ์ ์ด๋ฃจ์ด์ง๋ค๋ ๊ฐ์ ์๋, n๊ฐ์ ์ฃผ์ด์ง ๋ฆฌ์คํธ๋ฅผ ์ด์ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ์ ๋ ฌํ๋ ๋ฐ์๋ Θ(n^2) ๋งํผ์ ์๊ฐ์ด ๊ฑธ๋ฆฐ๋ค. ์ ํ ์ ๋ ฌ์ ์๊ณ ๋ฆฌ์ฆ์ด ๋จ์ํ๋ฉฐ ์ฌ์ฉํ ์ ์๋ ๋ฉ๋ชจ๋ฆฌ๊ฐ ์ ํ์ ์ธ ๊ฒฝ์ฐ์ ์ฌ์ฉ์ ์ฑ๋ฅ ์์ ์ด์ ์ด ์๋ค. ๊ทธ๋ฆผ์ผ๋ก ํ..

These are OCaml Library module "List" implementation. Useful when we handle list data type in OCaml. let rec length l = match l with | [] -> 0 | _::t -> 1 + length t (* tail-recursive version of length *) let length' l = let rec f l result = match l with | [] -> result | _::t -> f t (result+1) in f l 0 let hd l = match l with | [] -> raise (Failure "hd") | h::_ -> h let tl l = match l with | [] ..

์์ ๋ค์ OCaml๋ก ๊ตฌํํด ๋ณด์. OCaml quicksort code (* pick the first element as a pivot *) (* ascending order *) let rec qsort comp l = match l with | [] -> [] | p::t -> let (l1,l2) = List.partition (fun x -> comp x p print_int x;print_string " ") l; print_newline(); print_endline "result of qsort : "; List.iter (fun x -> print_int x;print_string " ") (qsort compare l); print_newline() OCaml Stack code ๋ชจ๋..

์ด์ ๊ฒ์๊ธ์ ์ด์ด OCaml์์ ๊ผญ ์์์ผ ํ ์ค์ํ ๊ฐ๋ ๋ค์ ๋ํด ๋ ์์๋ณด๋๋ก ํ์. ์ฃผ์ ๊ฐ๋ ๋ค : Pair, Tuple, List, Currying, Inductive type, match-with ๊ตฌ๋ฌธ, Polymorphic type, try-with-raise, module system, reference. OCaml Pair Pair๋ ๋ ๊ฐ์ ๊ฐ์ ํ๋ฒ์ ๋ฌถ๋ ๋ฐ ํ์ฉ๋๋ค. ์ ์๋ (x, y)๊ฐ์ ์์ผ๋ก ํ ์ ์์ผ๋ฉฐ, ํ์ ์ a * bํํ๋ก ํ๊ธฐ๋๋ค. Pair์ ๊ฐ ํญ์ ์กฐํํ๋๋ฐ fst์ sndํจ์๋ฅผ ์ฌ์ฉํ ์ ์๋ค. let p:(int * string) = (1, "a") let i = fst p (* int, 1 *) let s = snd p (* string, "a" *) let..

OCaml ์ธ์ด : Ocaml์ ์ฌ๋ฌ๊ฐ์ง ์ฌ์ฉ๋ฒ์ ๊ฐ์ง๋ ์์ (high-level)์ธ์ด์ด๋ค. ์ ์ฐจํ(imperative), ๊ฐ์ฒด์งํฅ(object oriented), ํจ์ํ(functional) ๋ฑ์ ํ๋ก๊ทธ๋๋ฐ์ ๋ชจ๋ ์ง์ํ๋ค. Java์ฒ๋ผ, ์๋์ผ๋ก ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ด๋ฆฌํด ์ฃผ๋ Garbage collector๊ฐ ์กด์ฌํ๋ค. ํ์ ์์คํ ์ด ๋ด์ฅ๋์ด ๋งค์ฐ ์์ ์ ์ผ๋ก ์ฌ์ฉํ ์ ์๋ค. ์ ์ฐจํ VS ๊ฐ ์ค์ฌํ ์ ์ฐจํ ์ธ์ด๋ ๊ธฐ๊ฒ์๊ฒ ์์๋๋ก ๋ช ๋ น์ ์ ๋ฌํ๋ค. ํจ์ํ ์ธ์ด์ ๊ฒฝ์ฐ, ๊ฐ ์ค์ฌ์ผ๋ก ๊ธฐ๊ณ์๊ฒ ์์ ๊ณ์ฐ์ ์ํค๋ ์์ผ๋ก ๋์ํ๋ค. OCaml ๊ธฐ์ด - ๊ฐ ์ ์ ์ ์ ๊ฐ let i = 1 ๋ฌธ์์ด ๊ฐ let s = "hello world" Boolean ๊ฐ let b = true unit let _ = print_e..

I'm introducing fine Korean restaurants/places where actual local Koreans usually go, not just tourist-targeted restaurants. Brief Review : - Name : Dos Tacos - Summary : Fine place to eat nice mexican foods, especially tacos. Well, it's actually street food, but I'm more of a begger than a prince, so street food would suffice to me. Oh, I love chimichanga. *Deadpool: TIME TO MAKE THE CHIMI-****..