lecture_12 - ECE 190 Lecture 12 September 29, 2011 Stack...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 190 Lecture 12 September 29, 2011 1 V. Kindratenko Stack Lecture Topics Stack data structure Lecture materials Textbook Ch. 10 Homework/Projects MP2.1 is out, due next Wednesday Announcements Exams will be available for pickup during the labs on Friday
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 190 Lecture 12 September 29, 2011 2 V. Kindratenko Stack concept Stack is an abstract data type that finds many uses Stack of books example o A new book always goes on top of the stack o We can only remove a book from the top of the stack Item (book) put last onto the stack of other items (books) will be the first item removed from the stack o Last In First Out (LIFO) Coin holder example: true mechanical stack implementation o First coin in is the last coin out Stack terminology o We say we push an element onto the stack when we add to the stack o We say we pop an element from the stack when we remove from the stack Stack implementation requires 4 operations o Push – to add to the stack o Pop – to remove from the stack o IsEmpty – to check if the stack is empty o IsFull – to check if the stack is full Conceptual hardware implementation 1995 1996 1998 1982 1995 1998 1982 1995 Initial State After One Push After Three More Pushes After One Pop / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / Yes Empty: TOP #18 / / / / / / / / / / / / / / / / / / / / / / / / No Empty: TOP #12 #5 #31 #18 / / / / / / No Empty: TOP #31 #18 / / / / / / / / / / / / / / / / / / No Empty: Initial State After One Push After Three More Pushes After Two Pops
Background image of page 2
ECE 190 Lecture 12 September 29, 2011 3 V. Kindratenko o Each time we push a new element onto the stack, we need to copy all the elements that are already in the stack to make space on top of the stack for the new element Not efficient A better way is to keep the elements “stationary”, and just move the pointer to the top of the stack o By convention, R6 holds the top of stack pointer
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/24/2012 for the course ECE 190 taught by Professor Hutchinson during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 7

lecture_12 - ECE 190 Lecture 12 September 29, 2011 Stack...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online