| Operation | Description |
|---|---|
| Enqueue | Adding an element to the end of the list using the append() method. |
| Dequeue | Removing an element from the start of the list using the pop(0) method. |
| Peek | Accessing the first element using the index [0]. |
queue=[]#Enqueue elementsqueue.append(1)queue.append(2)queue.append(3)#Dequeue elementfirst_elem=queue.pop(0)#Peek at the next elementnext_elem=queue[0]The data type most commonly used to implement a Queue data structure in Python is List.
Additional Context:
append() for enqueue (add to rear)pop(0) for dequeue (remove from front)collections.deque (optimized for O(1) at both ends)queue.Queue (thread-safe implementation)
queue = []
queue.append(10) # Enqueue
queue.append(20)
item = queue.pop(0) # Dequeue → 10
Correct Answer: (4) List.
Identify the part of the sentence that contains a grammatical error:
Each of the boys have submitted their assignment on time.
Rearrange the following parts to form a meaningful and grammatically correct sentence:
P. a healthy diet and regular exercise
Q. are important habits
R. that help maintain good physical and mental health
S. especially in today's busy world