Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- SQLD
- 윈도우11네트워크없이설치
- SQL
- windows11install
- 독학
- 상태공간트리
- mssql프로시저검색
- 윈도우11인터넷없이설치
- 분할정복법
- 프로세스에연결
- 선택정렬
- 알고리즘
- windows11setup
- 코테
- 코딩테스트
- mssql함수검색
- mssql호환성수준
- GROOUPING SETS
- it자격증추천
- 예제
- 삽입정렬
- adsp공부방법
- 순환
- mssql호환성수준확인
- 비밀번호
- 호환성수준변경
- It
- sql튜닝
- 톰캣버전확인
- w3wp.exe
Archives
- Today
- Total
404 not found
스텍과 큐 본문
스택 자료구조
: 먼저 들어 온 데이터가 나중에 나가는 형식
: 입구와 출구가 동일한 형태
ex) 박스 쌓기
파이썬(Python)
stack = [] #기본 리스트가 stack구조
stack.append(5)
stack.append(7)
stack.append(2)
sack.pop()
stack.append(3)
stack.append(1)
stack.pop()
print(stack[::-1]) #최상단 원소부터 출력
print(stack) # 최하단 원소부터 출력
결과=================================================
[3,7,5]
[5,7,3]
자바(JAVA)
import java.util.*;
public class Main {
public static void main(String[] args) {
Stack<Integer> s = new Stack<>();
s.push(5);
s.push(2);
s.push(2);
s.pop();
s.push(1);
s.push(2);
s.pop();
while (!s.empty()) {
System.out.print(s.peek() + " ");
s.pop();
}
}
}
결과=================================================
1,2,5
큐 자료구조
:먼저 들어 온 데이터가 먼저나가는 형식(선입선출)
ex) 터널
파이썬(Python)
from collections import deque #큐 구현을 위한 덱 라이브러리 추가
queue = deque()
queue.append(1)
queue.append(2)
queue.append(5)
queue.popleft()
queue.append(2)
queue.append(3)
queue.append(6)
queue.popleft()
print(queue)
queue.reverse()
print(queue)
결과=================================================
5,2,3,6
6,3,2,5
자바(JAVA)
import java.util.*;
public class Main {
public static void main(String[] args) {
Queue<Integer> q = new LinkedList<>();
q.offer(5);
q.offer(2);
q.offer(3);
q.poll();
q.offer(7);
q.offer(4);
q.poll();
while (q.isEmpty()) {
System.out.print(q.poll() + " ");
}
결과=================================================
3,7,4
'자료구조 > 코딩테스트 정리' 카테고리의 다른 글
퀵 정렬과 계수 정렬 (0) | 2021.10.19 |
---|---|
정렬알고리즘 (0) | 2021.10.19 |
트리자료구조 (0) | 2021.10.11 |
우선순위 큐(Priority Queue) (0) | 2021.10.11 |
1. 객체지향프로그래밍(OOP) 개념 (0) | 2021.09.14 |
Comments