Stack 이란?
스택은 LIFO 구조를 가진 구조체이다. (Last in First out)
A stack is a structure that uses the LIFO approach
한 마디로 후입선출인데

그림과 같이 움직인다고 보면 된다.
만약 스택이 가득 찬다면 한번쯤은 들어봤을
Overflow 상태가 된다. ( 스택오버플로우 )
If the stack is full and does not contain enough space to accept a new value to be pushed onto the stack is then considered to be in an "overflow" state.
사용처
이미 진행된것을 되돌리는 기능을 구현할떄 사용한다.
이 기능은 스택의 모든 변화를 지킴으로써 수행이 된다.
An "undo" mechanism in an application, this operation is accomplished by keeping all changes in a stack.
ex))
컴파일러의 신택스 체크 -> 스택으로 괄호를 체크해가며 확인
A compiler's syntax check for matching braces is implemented by using stack
인터넷 브라우저의 앞으로 , 뒤로가기 기능
Back/Forward stacks on browsers
게임 개발에서 "백트래킹" 예시
- 미로 길찾기
- 그래프의 한 영역에서 다른영역까지의 길
- 체스, 체커같은 게임들.
Game development – “Backtracking” for example
Find your way through a maze.
Find a path from one point in a graph (roadmap) to another point.
Play a game in which there are moves to be made (checkers, chess)
'개인공부 > 자료구조와 알고리즘' 카테고리의 다른 글
| Tree(트리 구조) (2) | 2023.02.06 |
|---|---|
| Linked List(링크드 리스트) (1) | 2022.07.20 |
| List (리스트) (0) | 2022.07.17 |
| (C++)Pointer 포인터 (0) | 2022.07.17 |