Day 9
Day 9: Doubly Linked Lists - Implementation and Comparison
9/60 Days
Doubly Linked Lists - Implementation and Comparison#
Welcome to Day 9 of our 60 Days of Coding Algorithm Challenge! Today, we’ll explore doubly linked lists, implement one from scratch, and compare it with singly linked lists.
What is a Doubly Linked List?#
A doubly linked list is a type of linked list where each node contains data and two pointers:
- A pointer to the next node
- A pointer to the previous node
This bi-directional linking allows for more flexible operations, especially when traversing the list in reverse or deleting nodes.
Implementing a Doubly Linked List#
Let’s implement a doubly linked list with basic operations:
1class Node:
2 def __init__(self, data):
3 self.data = data
4 self.prev = None
5 self.next = None
6
7class DoublyLinkedList:
8 def __init__(self):
9 self.head = None
10 self.tail = None
11
12 def is_empty(self):
13 return self.head is None
14
15 def …Keep your momentum going
Create a free account to unlock the full lesson, all 60 days, and track your progress as you go.
- Full access to all 60 daily lessons
- Track completion and build a daily streak
- Get interview-ready, one algorithm at a time
Join 2,900+ learners · 4.8/5 average rating