lec-07 - ECE 242 Data Structures and Algorithms...

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

View Full Document Right Arrow Icon
ECE 242 Data Structures and Algorithms http://www.ecs.umass.edu/~polizzi/Teaching/ECE242/ Stacks and Queues II Lecture 7                        Prof. Eric Polizzi                      
Image of page 1

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

View Full Document Right Arrow Icon
2 Summary previous lecture - Stacks Stack is an  abstract data structure  of type  LIFO (Last In First Out) Allowing access to the last item inserted. If removed, you get access to  the next-to-last item inserted, and so on .....  Complexity  O(1).  It is a simple useful tool in programming C B A Push Pop List of basic operations using a Stack push(item); pop(); peek() isEmpty() isFull() size()
Image of page 2
3 public Stack( int maxSize) { this. maxSize=maxSize; // set array size array = new Object [maxSize]; //create array top = -1 ; // no item yet } Summary of previous lecture- Stacks private int max; // capacity private int top; // top private Object[] array; //array   class Stack { // variables // constructors // methods } public boolean isEmpty() { /instructions/ } public boolean isFull() { /instructions/ } public int size() { /instructions/ } public Object peek() { /instructions/ } public Object pop() { /instructions/ } public void push( Object item) { /instructions/ } C B A max-1 4 3 2 1 0 top Array-based implementation
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern