๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์Šคํƒ2

[3.์Šคํƒ/ํ] stack, queue 1. Stack : ๋‹จ์–ด์˜ ์˜๋ฏธ์ฒ˜๋Ÿผ ๋ฐ์ดํ„ฐ๋ฅผ ์Œ“์•„ ์˜ฌ๋ฆฐ๋‹ค๋Š” ์˜๋ฏธ : ๋ฐฐ์—ด ๋Œ€์‹ ์— ์‚ฌ์šฉ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Œ : LIFO(Last In First Out) > ๋งˆ์น˜ ์ ‘์‹œ๋ฅผ ์Œ“์•„๋‘์—ˆ๋‹ค๊ฐ€ ๋งจ ์œ„๋ถ€ํ„ฐ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ, ๊ฐ€์žฅ ์ตœ๊ทผ์— ์ถ”๊ฐ€ํ•œ ํ•ญ๋ชฉ์ด ๊ฐ€์žฅ ๋จผ์ € ์ œ๊ฑฐ๋  ํ•ญ๋ชฉ์ด๋ผ๋Š” ๊ฒƒ. : ๋ฏธ๋กœ ์ฐพ๊ธฐ, ๊ด„ํ˜ธ ์œ ํšจ์„ฑ ์ฒดํฌ, ์žฌ๊ท€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋“ฑ์— ํ™œ์šฉ : ์ง์ ‘ new์—ฐ์‚ฐ์ž๋กœ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์‚ฌ์šฉ๊ฐ€๋Šฅ 2. Stack์˜ ์—ฐ์‚ฐ stack.pop() ๊ฐ€์žฅ ์ตœ๊ทผ ์›์†Œ ๋ฐ˜ํ™˜ ํ›„ ์ œ๊ฑฐ stack.peek() ๊ฐ€์žฅ ์ตœ๊ทผ ์›์†Œ ํ˜ธ์ถœ (์ œ๊ฑฐX) stack.push(e) ์š”์†Œ ์‚ฝ์ž… stack.isEmpty() ์Šคํƒ์ด ๋น„์–ด์žˆ๋Š” ๊ฒฝ์šฐ true๋ฐ˜ํ™˜, ์š”์†Œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ false๋ฐ˜ํ™˜ stack.search() ๊ฐ์ฒด๊ฐ€ ์กด์žฌํ•˜๋Š” ์ธ๋ฑ์Šค ๋ฐ˜ํ™˜(๋งˆ์ง€๋ง‰ ์š”์†Œ๋กœ๋ถ€ํ„ฐ .. 2020. 8. 31.
[๋ฐฑ์ค€ 9012] ๊ด„ํ˜ธ(Java) - Stack [๋ฌธ์ œ๋งํฌ] https://www.acmicpc.net/problem/9012 [ํ’€์ด์†Œ์Šค] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 package algorithm; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Stack9012 { public static void main(String[] args) throws NumberFormatException, IOExce.. 2020. 5. 4.