Stack

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1.

Stack
1.1. Định Nghĩa

Là cấu trúc dữ liệu để lưu trữ dữ liệu

Đặc điểm: có thứ tự

1.2. Push và Pop

Push là thêm 1 element vào trên cùng

Pop là xóa 1 element trên cùng

1.3. Lifo (Last in first out)

Thằng vào sau cùng là ra đầu tiên

1.4. Exceptions

Khi mà push vào stack đầy thì sẽ throw stackOverflowExceptions

Khi pop mà stack bị empty thì throw StackUnderflowExceptions hoặc StackemptyException

1.5. Các loại Stack

Simple Array Implementation

Dynamic array Implementation

LinkedList Implementation

3 loại có chung Stack Abstract Data Type (ADT) không biết Implementation là gì nhưng nó luôn có
function: Push; Pop; Top (lấy thằng đầu ra xem nhưng không xóa); Size; isEmptyStack; isFullStack;
DeleteStack

1.6. Ứng dụng

Cái đóng mở ngoặc, History, Ctrl Z; call funcion

1.7. Stack Implementations

Simple Array

Push O(1)
Pop O(1)
Size O(1)
Top O(1)
isEmptyStack O(1)
isFullStack O(1)
DeleteStack O(1)
Dynamic array

Push O(1) average


Pop O(1)
Size O(1)
Top O(1)
isEmptyStack O(1)
isFullStack O(1)
DeleteStack O(1)

LinkedList

Push O(1)
Pop O(1)
Size O(n)
Top O(1)
isEmptyStack O(1)
isFullStack O()
DeleteStack O(n)

You might also like