Question: Parallel arrays are two or more arrays where each element in one array corresponds to the elements at the same relative position (i.e., having the

Parallel arrays are two or more arrays where each element in one array corresponds to the elements at the same relative position (i.e., having the same index value) in the other arrays.

Consider the following use of parallel arrays to implement a linked list:

Two arrays, payload and pointer, are used. The payload array contains the items to be maintained in the linked list. For each item in the payload array, the corresponding position in the pointer array holds the next pointer, that is, the index value of the next item in the list. There is also a separate variable, headIndex, that maintains the index value for the first item on the list.

payload array positions that are not used are populated with null, and the corresponding pointerpositions are populated with -1. Note that the element in the pointer array corresponding to the last item on the list is also set to -1.

payload[headIndex] contains the first item in the list. payload[pointer[headIndex]] contains the second item in list etc.

Examine the populated payload and pointer arrays below, and given a headIndex value of 3, list the movies in the order in which they appear in the linked list.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!