Skip to content

Commit 87ead1d

Browse files
committed
Small edits to doubly linked list notes.
1 parent 27ffa56 commit 87ead1d

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

source/lectures/data/DLList.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ tags:
55

66
# Doubly Linked List
77

8-
Here is *yet* another implementation of the list abstract data type, using *doubly linked list*.
8+
## Motivation
99

10-
```{download="./code/projects/DLList_ICollection.zip"}
11-
!include code/projects/DLList_ICollection/DLList_ICollection/DLList.cs
12-
```
10+
We can implement the list abstract datatype using *doubly linked lists*.
1311

1412
The main differences with *singly* linked list are as follows:
1513

1614
- Instead of keeping only track of the first element (`first`), we keep track of both the first (`head`) and last (`tail`) elements.
1715
- Each `Cell` contains a pointer to the "next" element (as before), but also to the "previous" element.
1816
- Adding (or removing) to the right is now done in constant time, instead of linear time.
19-
- Traversing the list in opposite order (from end to beginning, or right to left) is now straightforward (cf. the `ToString` method above).
17+
- Traversing the list in opposite order (from end to beginning, or right to left) is now straightforward (cf. the `ToString` method).
2018
- The rest of the edits are about bookkeeping the `Previous` and `Next` attributes of the `Cell`, as well as updating the `tail` attribute. This makes removing and adding "in the middle of the list" a bit tricky.
19+
20+
## Implementation
21+
22+
Our implementation of doubly linked list realizes the ICollection interface:
23+
24+
```{download="./code/projects/DLList_ICollection.zip"}
25+
!include code/projects/DLList_ICollection/DLList_ICollection/DLList.cs
26+
```

0 commit comments

Comments
 (0)