A double linked list may be implemented in a workspace array by utilising only one index next. That is, we do not need to retain a distinct field back in the workspace array nodes to detect the backward linkages. The goal is to add a member workspace[current] into workspace[current] rather than the index of the next element on the list. The difference is the index of the next item less the index of the entry preceding current. We must additionally keep two pointers to subsequent nodes in the list, the current index and the prior index of the node right before current in the linked list. To find the next entry of the list, we calculate workspace[current].difference + previous; Similarly, to find the entry preceding previous, we calculate current − workspace[previous].difference;

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question

A double linked list may be implemented in a workspace array by utilising only one index next. That is, we do not need to retain a distinct field back in the workspace array nodes to detect the backward linkages. The goal is to add a member workspace[current] into workspace[current] rather than the index of the next element on the list. The difference is the index of the next item less the index of the entry preceding current. We must additionally keep two pointers to subsequent nodes in the list, the current index and the prior index of the node right before current in the linked list.
To find the next entry of the list, we calculate workspace[current].difference + previous; Similarly, to find the entry preceding previous, we calculate current − workspace[previous].difference;

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning