When every local link check passes

A playlist's doubly linked list has head = A, tail = D, and a recorded length of 6. The six nodes below are all allocated and are all claimed to belong to this one list. No nodes are inserted, removed, or modified during inspection.


Node

prev

next

A

null

B

B

A

C

C

B

D

D

C

null

E

F

F

F

E

E


Six allocated nodes are connected by the next and prev references specified in the accompanying table.


A node passes the reciprocal-link check when both applicable conditions hold: if x.next is not null, then x.next.prev == x; if x.prev is not null, then x.prev.next == x. A condition with a null link passes without following that link.


Complete the inspection report. Count distinct nodes, including each traversal's starting node. Follow next from head or prev from tail until reaching null or a previously visited node. Enter exact integers for counts and yes or no for the final row. A valid list must contain every claimed node in one chain between its endpoints, with reciprocal links and an accurate recorded length.

Inspection resultAnswer
Distinct nodes reached forward from head
Distinct nodes reached backward from tail
Allocated nodes passing the reciprocal-link check
Allocated nodes unreachable forward from head
Is the complete claimed list valid?

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Doubly Linked Lists Questions: