Deque is double ended queue, which like the doubly linked list with having frond/head in the start and last/tail in the end of the list.
Stack using Deque
Input:
push(1)
push(2)
push(3)
push(4)
Output:
4
3->2->1
Queue using Deque
Input:
enqueue(1)
enqueue(2)
enqueue(3)
enqueue(4)
Output:
1
2->3->4
No comments:
Post a Comment