2020-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜์•Œ๊ณ ๋ฆฌ์ฆ˜โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)

1 minute read

2020-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜์•Œ๊ณ ๋ฆฌ์ฆ˜โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)


<Greedy Algorithm; ํƒ์š• ์•Œ๊ณ ๋ฆฌ์ฆ˜>์˜ ์•„์ด๋””์–ด๋Š” ๊ฐ„๋‹จํ•˜๋‹ค.

thinking ahead sv. choosing immediate advantage

๋ชฉ์ ์„ ๋‹ฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด ์ง€๊ธˆ ๋ช…ํ™•ํ•˜๊ณ  ์ฆ‰๊ฐ์ ์ธ ๋ˆˆ์•ž์˜ ์ด๋“์„ ์ทจํ•œ๋‹ค.

<Greedy Algorithm>์ด ์‚ฌ์šฉ๋˜๋Š” ์˜ˆ๋Š” ๋‹ค์–‘ํ•˜๋‹ค. Weighted Graph์—์„œ Minimum Spanning Tree๋ฅผ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜, ์ผ์ •์„ ์Šค์ผ€์ฅด๋ง ํ•˜๊ฑฐ๋‚˜, ๋˜๋Š” ๋ฌธ์„œ๋ฅผ ์••์ถ•ํ•˜๊ธฐ ์œ„ํ•œ Huffman Encoding ๋“ฑ์—์„œ <Greedy Algorithm>์„ ์‚ฌ์šฉํ•œ๋‹ค.

๊ฐœ์ธ์ ์œผ๋กœ ๋ฌธ์ œ๋ฅผ ํ’€ ๋•Œ, Greedy๋กœ ํ’€์ง€, DP๋กœ ํ’€์ง€ ์ข€ ํ—ท๊ฐˆ๋ฆฌ๋Š” ์ƒํ™ฉ๋“ค์ด ์žˆ๋Š”๋ฐ, ๋ณธ์ธ์€ ๋ณดํ†ต Greedy๋กœ ํ’€์—ˆ์„ ๋•Œ์˜ ๋ฐ˜๋ก€ ์œ„์ฃผ๋กœ ์ƒ๊ฐํ•˜๋Š” ํŽธ์ด๋‹ค. ๋งŒ์•ฝ Greedy๋กœ ํ’€์—ˆ์„ ๋•Œ, ๋ฐ˜๋ก€๊ฐ€ ์žˆ๋‹ค๋ฉด Greedy๋กœ ์ ‘๊ทผํ•˜์ง€ ์•Š๊ณ  ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์„ ์ƒ๊ฐํ•ด๋ณธ๋‹ค.

๋•Œ๋กœ๋Š” Greedy์™€ DP๋ฅผ ํ•จ๊ป˜ ์จ์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค. ๋‘ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ๋ฐฐํƒ€์ ์ธ ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ๋ฌธ์ œํ•ด๊ฒฐ์˜ ๋„๊ตฌ์ผ ๋ฟ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‘˜์˜ ์•„์ด๋””์–ด๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜๋„ ์žˆ๋‹ค ๐Ÿ˜


์ด๋ฒˆ ์ฑ•ํ„ฐ์—์„œ ๋‹ค๋ฃจ๋Š” ๋ฌธ์ œ๋“ค์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

Categories:

Updated: