X632: insertListAfterRef13

Consider the following class definition:
   class Link{
      Object data;
      Link next;
   }
p is a reference to the first node of list L. Integer ref is the value of a node in L. Link q is a reference to a list that you would append after the node containing ref (if there was one). If q or ref are null or don’t exist, then p should remain unchanged. Return list p with the addition of q.

Initial Setup Final Configuration

Examples:

insertListAfterRef(Link.CreateList(1,2,3),1,Link.CreateList(5,6,7,8)) -> Link.CreateList(1,5,6,7,8,2,3)

Your Answer:

Reset
Visualize

Feedback

Your feedback will appear here when you check your answer.