Ans FAQ 2 - CS 4-11
Ans FAQ 2 - CS 4-11
b)
**Circuit Switching** and **Packet Switching** are two different
methods of transmitting data across a network:
def Pop_elements(Stu_Stk):
if not Stu_Stk:
print("Stack Empty")
else:
while Stu_Stk:
Stu_ID = Stu_Stk.pop()
print(f"Popped Student ID: {Stu_ID}")
Stu_dict = {
101: (75, 82, 88),
102: (85, 90, 78),
103: (88, 84, 90),
104: (80, 79, 85),
105: (60, 70, 95)
}
Stu_Stk = []
Push_elements(Stu_Stk, Stu_dict)
Pop_elements(Stu_Stk)
Ans 7.
Push_book :-
Pop_book:-
def pop_book(BooksStack):
if len(BooksStack) == 0:
return "Underflow"
else:
return BooksStack.pop()
peep:-
def peep(BooksStack):
if len(BooksStack) == 0:
return None
else:
return BooksStack[-1]
Ans 8.
1)
push_even(N): Pushes all even integers from the list N into the
stack EvenNumbers.
code:-
def push_even(N):
EvenNumbers = []
for number in N:
if number % 2 == 0:
EvenNumbers.append(number)
return EvenNumbers
2)
pop_even(): Pops the topmost even number from the stack and
returns it, or shows "Empty" if the stack is empty.
code:-
def pop_even(EvenNumbers):
if len(EvenNumbers) == 0:
return "Empty"
else:
return EvenNumbers.pop()
3)
Disp_even(): Displays all the elements in the stack without deleting
them, or shows "None" if the stack is empty.
code:-
def D
isp_even(EvenNumbers):
if len(EvenNumbers) == 0:
return "None"
else:
return EvenNumbers
Ans 9.
class CustomerStack:
def __init__(self):
self.stack = []
def Pop_element(self):
if self.stack:
while self.stack:
print(self.stack.pop())
else:
print("Stack Empty")
customer_details = [
["Gurdas", "99999999999", "Goa"],
["Julee", "8888888888", "Mumbai"],
["Murugan", "77777777777", "Cochin"],
["Ashmit", "1010101010", "Goa"]
]
status = CustomerStack()
status.Push_element(customer_details)
status.Pop_element()
Ans 10.
def Push(SItem):
stack = []
count = 0
for item, price in SItem.items():
if price > 75:
stack.append(item)
count += 1
for item in stack:
print(item)
print(f"The count of elements in the stack is {count}")
Ans 11.
### 1. **PUSH**:
### 2. **POP**:
The `POP` operation removes and returns the element from the
top of the stack. It decreases the size of the stack by one.
### 3. **OVERFLOW**:
### 4. **UNDERFLOW**:
b)
A
AB
AB*
ABC
ABC+
ABCD
ABCDE
ABCDE/
ABCDE/+
ABCDE/+*
ABCDE/+*+