SQ_implementation - Implementation of stack using an array...

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

View Full Document Right Arrow Icon
1 Implementation of stack using an array We have seen in the lecture class how a stack can be implemented with push and pop functions to handle integers. In this section we shall show how to handle a situation when we have to deal both with integers and character information. Let us consider a factory where goods of varying quality are being produced in batches. We assume that all goods produced in a particular batch have the same quality. As the items are being produced, we want to store the information regarding the number of items produced and the quality of that batch ( ‘H’ for high quality, ‘G’ for good quality, ‘A’ for average quality etc.) on a stack using PUSH function. To deliver the items to a client, we want to use the POP function. The POP function is supposed to remove the items from the stack. We are also interested to find out if the stack is full or empty at any point in time using the functions ISFULL and ISEMPTY. We start by declaring the following structure which has two arrays, one storing the number of items being produced in every batch, while the other storing the quality of the goods in that batch. The variable top indicates the position of the last item in an array. The variable MAXSTACK defines the maximum size of the stack.
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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