Skip to main contentSkip to solution

_____________ function always adds an element at the rear of a queue.

Solution

✅ Correct Option: 2

In Python, a queue is usually implemented with a list, and append() always adds the new element at the end of the list, which is the rear of the queue. Elements are then removed from the front (FIFO), for example with pop(0).


Option 1: add() is a method of sets, not lists.

Option 3: insert(i, x) puts the element at any given index, so it does not always add at the rear.

Option 4: push is the stack operation name, and Python lists have no push() method.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question