0% found this document useful (0 votes)
7 views4 pages

Stack Material Q&A and Code Examples

Chapter 5 covers stack material through assertion and reasoning questions, multiple-choice questions, program completion tasks, and code snippets. Key concepts include stack operations like push and pop, the Last In First Out (LIFO) principle, and handling underflow and overflow conditions. The document provides various examples and functions related to stack implementation in programming.

Uploaded by

cyberselvaselva
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Stack Material Q&A and Code Examples

Chapter 5 covers stack material through assertion and reasoning questions, multiple-choice questions, program completion tasks, and code snippets. Key concepts include stack operations like push and pop, the Last In First Out (LIFO) principle, and handling underflow and overflow conditions. The document provides various examples and functions related to stack implementation in programming.

Uploaded by

cyberselvaselva
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 5 - Stack Material (All Questions & Answers)

ASSERTION & REASONING

1. A: True, R: True, R is correct explanation

2. A: False, R: True

3. A: True, R: True, R is correct explanation

4. A: True, R: True, R is correct explanation

5. A: False, R: True

OBJECTIVE TYPE MCQ

1. (b) STACK

2. (c) list

3. (d) LIFO

4. (b) Last in First Out

5. (c) Persons buying movie tickets from a counter

6. (c) PUSH and POP

7. (a) peak operation

8. (a) Simulation of recursion

9. (c) Stack does not follow LIFO rule

10. (c) Push

11. (d) Pop

12. (b) Stack

13. (c) POP

14. (d) Top

15. (d) Overflow

16. (b) Overflow

17. (c) Underflow

18. (b) Stack = [8,10,100]

19. (a) Underflow

20. (b) Top == len(st) - 1


Chapter 5 - Stack Material (All Questions & Answers)

21. (a) 1202esbc

22. (b) 70

23. (d) IndexError: pop from empty list

24. (d) Data Transfer between Process

25. (a) [2,3,4,10]

26. 4

27. (a) 1

28. (a) 8 5 2 51

PROGRAM COMPLETION (Q29 & Q30)

Q29 Answers:

1. Stack = []

2. range(len(list_all))

3. append(i)

4. Stack after push: [20, 30, 2]

5. len(Stack)

6. pop()

Q30 Answers:

1. append

2. len(Student_List)==0

3. pop

4. Student_List[::-1]

5. print

3-MARKS QUESTIONS (Code Snippets)

Q1:

def Push(Stu, roll, name, cls):


Chapter 5 - Stack Material (All Questions & Answers)

[Link]([roll, name, cls])

def MakePop(Stu):

if len(Stu) == 0:

print("Underflow")

else:

print("Deleted:", [Link]())

Q2:

def Push(PackageDescription, emp):

[Link](emp)

def Pop(PackageDescription):

if len(PackageDescription) == 0:

print("Underflow")

else:

print("Deleted:", [Link]())

Q3:

def push_stack(L, Stack):

for i in L:

if i % 15 == 0:

[Link](i)

def pop_stack(Stack):

while Stack:

print([Link]())

Q4:

def Push_element(status, data):

if data[3] == "Anesthesia":
Chapter 5 - Stack Material (All Questions & Answers)

[Link]([data[0], data[1]])

def Pop_element(status):

while status:

print([Link]())

print("Stack Empty")

Q5:

def Push(KItem):

stack = []

total = 0

count = 0

for item, price in [Link]():

if price < 100:

[Link](item)

total += price

count += 1

print("\n".join(stack))

if count > 0:

print("The average price of an item is", total / count)

You might also like