recategorized by
3,038 views
0 votes
0 votes

If we have six stack operationspushing and popping each of $A, B$ and $C$-such that push $(A)$ must occur before push $(B)$ which must occur before push $(C)$, then $A, C, B$ is a possible order for the pop operations, since this could be our sequence : push $(A)$, pop $(A)$, push $(B)$, push $(C)$, pop $(C)$, pop $(B)$. Which one of the following orders could not be the order the pop operations are run, if we are to satisfy the requirements described above?

  1. $ABC$
  2. $CBA$
  3. $BAC$ 
  4. $CAB$
recategorized by

2 Answers

1 votes
1 votes
As question says, push (A) (A) must occur before push (B) (B)which must occur before push (C)

So option a is valid as

first push A than pop A

Than push B again pop B

Than push C again pop c

So here ABC is valid pop sequence

(B)option

Push A

Push B

Push C

Pop all we will get CBA sequence so its valid

Option (c)

Push A

Push B  now pop B than again pop C  now push C now pop C

So  BCA is valid sequence

(D) option is not valid

So( d) option answer

Related questions

1 votes
1 votes
2 answers
1
makhdoom ghaya asked Sep 16, 2016
2,131 views
Which of the following expression is represented by the parse tree ?$(A + B) ^{*} C$$A + ^{*} BC$$A + B * C$$A * C + B$
1 votes
1 votes
2 answers
2
makhdoom ghaya asked Sep 15, 2016
4,645 views
In a $B$ tree of order $5$, the following keys are inserted as follows : $7, 8, 1, 4, 13, 20, 2, 6$ and $5$ How many elements are present in the root of the tree ?$1$ $2$...
0 votes
0 votes
3 answers
3
makhdoom ghaya asked Sep 15, 2016
2,299 views
A chained hash table has an array size of $100$. What is the maximum number of entries that can be placed in the table ?$100$$200$$10000$There is no upper limit
2 votes
2 votes
1 answer
4
makhdoom ghaya asked Sep 15, 2016
5,237 views
In a complete binary tree of n nodes, how far are the two most distant nodes ? Assume each edge in the path counts as !About $\log_{2} n$About $2 \log_{2} n$About $n \log...