search
Log In
1 vote
1.4k views

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$
in DS
recategorized by
1.4k views

2 Answers

1 vote
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
0 votes

Below is the dependency graph

Related questions

1 vote
3 answers
1
835 views
Which of the following expression is represented by the parse tree ? $(A + B) ^{*} C$ $A + ^{*} BC$ $A + B * C$ $A * C + B$
asked Sep 16, 2016 in DS makhdoom ghaya 835 views
1 vote
2 answers
2
1.9k 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$ $3$ $4$
asked Sep 16, 2016 in DS makhdoom ghaya 1.9k views
0 votes
3 answers
3
945 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
asked Sep 16, 2016 in DS makhdoom ghaya 945 views
1 vote
1 answer
4
1.7k 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_{2} n$ About $2n$
asked Sep 16, 2016 in DS makhdoom ghaya 1.7k views
...