1,632 views
2 2 votes
Let S be a stack with operations push, pop, top, empty. What is displayed after following segment of code executes .

                               for(i=1; i<=5; i++)

                               s.push(i);

                               while(!s.empty())

                               printf("%d", s.top());

ans with explanation

Please log in or register to answer this question.

Position:
Show:

Related questions

1 1 vote
1 1 answer
1.6k
1.6k views
amit166 asked Aug 8, 2018
1,584 views
pseudo code of stackdeclare a stack of characterswhile (there are more character in the word to read){read a character push the character on the stack}while(the stack i...
9 9 votes
2 2 answers
418
418 views
GO Classes asked Jul 27
418 views
Given a stack $S$ with $5$ elements from top to bottom as:$2, 4, 6, 8, 10$and an empty queue $Q$.First, remove the elements one by one from $S$ and insert them into $Q$.T...
7 7 votes
1 1 answer
489
489 views
GO Classes asked Jul 27
489 views
Which of the following statements are true?$\text{S1.}$ Stack operations $\texttt{push}$, $\texttt{pop}$, and $\texttt{isEmpty}$ can be worst-case $O(1)$ for a linked-lis...
7 7 votes
1 1 answer
315
315 views
GO Classes asked Jul 10
315 views
Assume there are $n$ elements in the data structure. Consider the following statements:$\text{S1}:$ A stack can be implemented using a linked list such that each individu...