diff options
| author | mo khan <mo.khan@gmail.com> | 2020-06-21 16:36:11 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-06-21 16:36:11 -0600 |
| commit | c53307c2aa6962107d1cb7d4d8ab2d328045f70a (patch) | |
| tree | f293f4150a56ffefea7e4667007619fa1dbd2f8d /unit | |
| parent | 39ff7205b9e2390fb659d170ebbf6925a50c066f (diff) | |
Swap items in singly linked list
Diffstat (limited to 'unit')
| -rw-r--r-- | unit/03/README.md | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/unit/03/README.md b/unit/03/README.md index 83cc8c3..91b31ee 100644 --- a/unit/03/README.md +++ b/unit/03/README.md @@ -12,3 +12,28 @@ Go to Data Structure Visualizations at http://www.cs.usfca.edu/~galles/visualiza * Queues: Linked List Implementation * Lists: Array Implementation (available in Java version) * Lists: Linked List Implementation (available in Java version) + +# Linked Lists + +Have advantages and disadvantages over array based List interface. + +Advantage + +* more dynamic + +Disadvantage: + +* using `get(i)` or `set(i, x)` in constant time. + +## Singly-Linked List + +SLList: is a sequence of Nodes with a reference to a value and the next node. + +```java +class Node { + T x; + Node next; +} +``` + +For efficiency the variables `head` and `tail` are used to keep track of the first and last node. |
