Week6 김수빈 1600 말이되고픈원숭이 풀이 #142
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
풀이
리뷰 요청 사항
느낀점 🙉 🐴
(1) 번이 LinkedList()로 제출한 결과
(2) 번이 ArrayDeque()로 제출한 결과 입니당.
Queue 구현할 때 ArrayDeque로 구현하는 것이 LinkedList로 구현하는 것보다 빠르다고 Java API document에서 설명하고 있다
이유는 첫 번째로, 수행 속도
ArrayDeque 는 Array에 의해 지원되면 cache locality (데이터에 대한 접근이 시간적 혹은 공간적으로 가깝게 발생하는 것) 더 친숙하다고 한다.
LinkedList 는 다음 노드가 있는 곳으로 가려고 다른 간접적은 경로를 거쳐간다.
두번째로 메모리
ArrayDeque 는 다음 노드에 대한 추가 참조를 유지할 필요가 없어 메모리적으로 효율적이다
쉽게 설명하면
삽입 큐의 자료구조 상 FIFO 특성으로 중간에 삽입되거나 삭제되는 경우가 없다.
양 끝에서만 삽입 삭제가 일어났다면 시간 복잡도 O(1)으로 리스트와 별 차이 없음 !!!
ArrayDeque vs LinkedList
[참고]
https://chucoding.tistory.com/52