Where can one use a (doubly-linked list) Positional List ADT? When the developer wants O(n)
memory and O(1)
(non-amortized behaviors) to an arbitrary position in the list? I would like to see an example of using a positional list. What would be the advantage of using a positional list over using an array-based sequence?
If your program often needs to add new elements to or delete elements from your data collection a list is likely to be a better choice than an array.
Deleting the element at position N of an array require a copy operation on all elements after element N. In principle:
Arr[N] = Arr[N+1]
Arr[N+1] = Arr[N+2]
...
A similar copy is needed when inserting an new element, i.e. to make room for the new element.
If your program frequently adds/deletes element, the many copy operations may hurt performance.
As a part of these operations the position of existing elements changes, i.e. an element at position 1000 will be at either position 999 or 1001 after an element is deleted/added at position 50.
This can be a problem if some part of your program has searched for a specific element and saved its position (e.g. position 1000). After an element delete/add operation, the saved position is no longer valid.
A (doubly-linked) list "solves" the 3 problems described. With a list you can add/delete elements without copying existing elements to new positions. Consequently, the position of a specific element (e.g. a pointer to an element) will still be valid after an add/delete operation.
To summarize: If your program (frequently) adds or deletes random located elements and if your program requires that position information isn't affected by add/delete operations, a list may be a better choice than an array.