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 |
Tags
- 딕셔너리
- 2P1L
- 신경망
- 소행성
- 최단 경로
- Python
- Class
- 코드업
- 자료형
- 미분 방정식
- 델
- cURL
- java
- 회로이론
- 강화학습
- 백트래킹
- 자바
- 이진탐색트리
- 계단 오르기
- 딥러닝
- 벡터해석
- 함수
- 선적분
- 파이썬
- Asteroid RL
- dictionary
- 벡터 해석
- 피보나치 수열
- BST
- auto-encoder
Archives
- Today
- Total
Zeta Oph's Study
[Data Structure (Java)] Queue 본문
https://crane206265.tistory.com/77
[Data Structure (Java)] Stack
https://crane206265.tistory.com/76 [Data Structure (Java)] SLL (Singly Linked List)https://crane206265.tistory.com/75 [Data Structure (Java)] Generichttps://crane206265.tistory.com/74?category=1076637 [Data Structure (Java)] Arrayhttps://crane206265.ti
crane206265.tistory.com
저번에 stack을 다루었으니, 이번에는 queue입니다. stack과 queue의 비교는 저번글에 있으니 참고하시면 될 것 같습니다.
Queue API
API of Queue<E> class
methods | explanation |
void enqueue(E e) | add an item to the collection (add to end) |
E dequeue() | remove and return the item least recently added (remove from beginning) |
E first() | return the first element |
boolean isEmpty() | return if stack is empty |
int size() | return the size of stack |
Queue implementation - Linked List
using SLL class,
public class LinkedQueue<E> implements Queue<E> {
private SinglyLinkedList<E> list = new SinglyLinkedList<>();
public LinkedQueue() {};
public int size() { return list.size(); }
public boolean isEmpty() { return list.isEmpty(); }
public void enqueue(E e) { list.addLast(e); }
public E first() { return list.first(); }
public E dequeue() { return list.removeFirst(); }
}
* enqueue : addLast() / dequeue : removeFirst()
<-- to implement operation as running time O(1)
(removeLast() : O(n))
Properties about Linked-List queue
- running time analysis : O(1) for every operation
- memory use : scalable
'프로그래밍 > Java' 카테고리의 다른 글
[Data Structure (Java)] Iterator (1) | 2024.05.12 |
---|---|
[Data Structure (Java)] List & Dynamic Array (3) | 2024.05.11 |
[Data Structure (Java)] Stack (1) | 2024.05.09 |
[Data Structure (Java)] SLL (Singly Linked List) (1) | 2024.05.09 |
[Data Structure (Java)] Generic (1) | 2024.05.07 |