JEE Exam  >  JEE Questions  >  Stack A has the entries a, b, and c (with a o... Start Learning for Free
Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible?
Most Upvoted Answer
Stack A has the entries a, b, and c (with a on top). Stack B is empty....
Introduction

This question is related to the permutation of three elements (a, b, and c) in two stacks A and B. We need to determine which permutation is not possible.

Permutations

There are six possible permutations of three elements (a, b, and c):

  • abc

  • acb

  • bac

  • bca

  • cab

  • cba



Solution

We can solve this problem by analyzing each permutation and checking if it is possible or not. We will use the following notations for the stacks:

  • A: original stack with entries a, b, and c

  • B: empty stack


We will also use the following operations:

  • pop(A): remove the top element from stack A

  • pop(B): remove the top element from stack B

  • push(B, x): push element x onto stack B

  • print(x): print element x



abc

We can print a, then push b to B, then push c to B, and finally pop and print elements from B.

pop(A) -> print(a)
pop(A) -> push(B, b)
pop(A) -> push(B, c)
pop(B) -> print(c)
pop(B) -> print(b)

Therefore, permutation abc is possible.

acb

We can print a, then push c to B, then push b to B, and finally pop and print elements from B.

pop(A) -> print(a)
pop(A) -> push(B, c)
pop(A) -> push(B, b)
pop(B) -> print(b)
pop(B) -> print(c)

Therefore, permutation acb is possible.

bac

We can push b to B, then print a, then push c to B, and finally pop and print elements from B.

pop(A) -> push(B, b)
pop(A) -> print(a)
pop(A) -> push(B, c)
pop(B) -> print(c)
pop(B) -> print(b)

Therefore, permutation bac is possible.

bca

We can push b to B, then push c to B, then print a, and finally pop and print elements from B.

pop(A) -> push(B, b)
pop(A) -> push(B, c)
pop(A) -> print(a)
pop(B) -> print(c)
pop(B) -> print(b)

Therefore, permutation bca is possible.

cab

We can print a, then push b to B, then print c, and finally pop and print elements from B.

pop(A) -> print(a)
pop(A) -> push(B, b)
pop(A) -> print(c)
pop(B) -> print(b)
Explore Courses for JEE exam
Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible?
Question Description
Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible? for JEE 2024 is part of JEE preparation. The Question and answers have been prepared according to the JEE exam syllabus. Information about Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible? covers all topics & solutions for JEE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible?.
Solutions for Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible? in English & in Hindi are available as part of our courses for JEE. Download more important topics, notes, lectures and mock test series for JEE Exam by signing up for free.
Here you can find the meaning of Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible? defined & explained in the simplest way possible. Besides giving the explanation of Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible?, a detailed solution for Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible? has been provided alongside types of Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible? theory, EduRev gives you an ample number of questions to practice Stack A has the entries a, b, and c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An ontry popped out of stack B and can only be printed. In this arrangement, which of the following permutations of a, b, and c are not possible? tests, examples and also practice JEE tests.
Explore Courses for JEE exam

Top Courses for JEE

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev