What is the purpose of following function?
def fun (myqueue):
if not(isEmpty(myqueue)):
return myqueue.pop(0)
else:
print("Empty")
What is the purpose of following function?
def fun (myqueue):
if not(isEmpty(myqueue)):
return myqueue.pop(0)
else:
print("Empty")
Solution
✅ Correct Option: 1
If the queue is not empty, myqueue.pop(0) removes and returns the element at index 0, which is the front of the queue. If it is empty, the function prints "Empty". This is the dequeue operation.
Option 2: rear deletion would be pop() with no argument, which removes the last element.
Option 4: pop(0) removes the element as well as returning it. Peek would use myqueue[0].
Related questions:
2026: 24 May Shift 1
2026: 19 May Shift 1
2026: 11 May Shift 2