VOOZH about

URL: https://www.geeksforgeeks.org/dsa/deque-traversal/

⇱ Deque Traversal - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Deque Traversal

Last Updated : 23 Jul, 2025

Given a deque dq containing integer elements, the task is to traverse the dq and print its elements of it.

Examples:

Input: dq = [1, 2, 3, 4, 5]
Output: 1 2 3 4 5
Explanation: We print elements of deque from from front to back

Input: dq = [1]
Output: 1

Deque Traversal refers to the process of accessing each element of the deque, typically to read or process the values stored within.


Output
1 2 3 4 5 

Time Complexity: O(n)
Auxiliary Space: O(1)


Comment
Article Tags:
Article Tags: