0
0
Data Structures Theoryknowledge~15 mins

Deque (double-ended queue) in Data Structures Theory - Mini Project: Build & Apply

Choose your learning style9 modes available
Deque (double-ended queue)
πŸ“– Scenario: Imagine you are managing a line of customers waiting for service at a bank. Sometimes customers join the line at the back, and sometimes VIP customers join at the front. Also, customers can leave from either end when served.
🎯 Goal: You will build a simple representation of a deque (double-ended queue) using a list. You will add customers to both ends and remove customers from both ends, simulating how a deque works.
πŸ“‹ What You'll Learn
Create a list called deque with initial customers 'Alice' and 'Bob'
Create a variable called vip_customer with the value 'Eve'
Add the vip_customer to the front of the deque
Remove the last customer from the deque
πŸ’‘ Why This Matters
🌍 Real World
Deques are used in real life to manage lines where people can join or leave from either end, like customer service lines or task scheduling.
πŸ’Ό Career
Understanding deques helps in programming tasks that require flexible data structures, such as managing tasks, undo features, or buffering data streams.
Progress0 / 4 steps
1
Create the initial deque
Create a list called deque with the exact customers 'Alice' and 'Bob' in that order.
Data Structures Theory
Need a hint?

Use square brackets to create a list with two strings: 'Alice' and 'Bob'.

2
Add a VIP customer variable
Create a variable called vip_customer and set it to the string 'Eve'.
Data Structures Theory
Need a hint?

Assign the string 'Eve' to the variable vip_customer.

3
Add VIP customer to the front of the deque
Use the insert method on deque to add vip_customer at the front (index 0).
Data Structures Theory
Need a hint?

Use deque.insert(0, vip_customer) to add Eve at the front.

4
Remove the last customer from the deque
Use the pop method on deque without arguments to remove the last customer.
Data Structures Theory
Need a hint?

Use deque.pop() to remove the last item from the list.