TAILIEUCHUNG - Lecture Algorithms and data structures (CSC112) - Chapter 11

Lecture Algorithms and data structures: Chapter 11- Stacks. An Abstract Stack (Stack ADT) is an abstract data type which emphasizes specific operations: Uses a explicit linear ordering, insertions and removals are performed individually, there are no restrictions on objects inserted into (pushed onto) the queue that object is designated the back of the queue,. This topic discusses the concept of a stack: Description of an Abstract Stack, list applications, implementation, example applications, standard template library. | Review Introduction Representation of Linear Array In Memory Operations on linear Arrays Traverse Insert Delete Example Stack Introduction Stack in our life Stack Operations Stack Implementation Stack Using Array Stack Using Linked List Use of Stack Introduction A Stack is an ordered collection of items into which new data items may be added/inserted and from which items may be deleted at only one end A Stack is a container that implements the Last-In-First-Out (LIFO) protocol Stack in Our Life Stacks in real life: stack of books, stack of plates Add new items at the top Remove an item from the top Stack data structure similar to real life: collection of elements arranged in a linear order. Can only access element at the top Stack Operations Push(X) – insert X as the top element of the stack Pop() – remove the top element of the stack and return it. Top() – return the top element without removing it from the stack. A primary concern for this course is efficiency. You might believe that faster computers make it unnecessary to be concerned with efficiency. However So we need special training. Stack Operations push(2) top 2 push(5) top 2 5 push(7) top 2 5 7 push(1) top 2 5 7 1 1 pop() top 2 5 7 push(21) top 2 5 7 21 21 pop() top 2 5 7 7 pop() 2 5 top 5 pop() 2 top A primary concern for this course is efficiency. You might believe that faster computers make it unnecessary to be concerned with efficiency. However So we need special training. Stack Operations Example push(5) top 5 push(8) top 5 8 push(3) top 5 8 3 push(9) top 5 8 3 9 9 pop() top 5 8 3 3 pop() top 5 8 8 pop() 5 top 5 pop() A primary concern for this course is efficiency. You might believe that faster computers make it unnecessary to be concerned with efficiency. However So we need special training. Stack Operation The last element to go into the stack is the first to come out: LIFO – Last In First Out. What happens if we call pop() and there is no element? Have IsEmpty() boolean .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.