Dear students join my telegram group for all assignments, GDBs and Quizzes Solutions. Thanks Join this https://t.me/VUALLINONE
cs301 final term solved papers by moaaz. Stacks: Let’s mention another important arrangement. you want to have a good idea of stacks.Some samples of stacks in real world are stack of books, stack of plates etc. We canadd new items at the highest of the stack or remove them from the highest.
we will onlyaccess the weather of the stack at the highest. Following is that the definition of stacks. “Stack may be a collection of elements arranged during a linear order”Let’s see an example to know this.
Suppose we’ve some video cassettes. Wetook one cassette and put it on the table. We get another cassette and put it on the topof first cassette. Now there are two cassettes on the table- one at the highest of other.
Nowwe take the third cassette and stack it on the 2. Take the fourth cassette and stack iton the three cassettes.Now if we would like to require the cassette, we will get the fourth cassette which is at the topand remove it from the stack.
Now we will remove the third cassette from the stackand so on. Suppose that we’ve fifty cassettes stacked on one another and need toaccess the primary cassette that’s at rock bottom of the stack. what is going to happen?
All thecassettes will fell down. it’ll not happen precisely the same within the computer. Theremay be some problem. It doesn’t mean that our arrangement is wrong. As we seein the above example that the highest most cassette are going to be removed first and therefore the newcassette are going to be stacked at the highest.
An equivalent example are often repeated with the books.In the lifestyle, we affect the stacked goods very carefully.Now we’ll discuss the way to create a stack arrangement or a factory, getting to createstack object for us.
What is going to be the attributes of this object? During the discussion onthe list, we came to understand that a programmer adds values within the list, removes valuesfrom the list and moves forward and backward.
Just in case of a stack too, we would like to addthings and take away things. we’ll not move forward or backward within the stack. Newitems are often added or removed at the highest only. we will not suggest the removal of themiddle element of the stack.