Consider a Single Linked List (SLL) of nodes, where ‘node’ is a type with two fields: integer data and the node type reference ‘next’ that refers to the next node in the list. For each part given...


Consider a Single Linked List (SLL) of nodes, where ‘node’ is a type with two fields: integer data and the node type reference ‘next’ that refers to the next node in the list. For each part given below consider the SLL and the code given in the second column. Following the execution of the code, show the resulting list (in the answer box, for each part, use the arrow key to draw the list as:      head-----> ? -------> ? --------> ?).
























List and Java Code



a




head

1

2

3

4

null



node ptr=head;


node newnode = new node(0);  // data=0


head = newnode;


newnode.next=ptr;



b




head

1

2

3

4

null



node ptr=head;


node newnode = new node(6);  // data=6


while(ptr.next!=null) {


      ptr=ptr.next;


}


ptr.next=newode;




c




head

1

2

3

4

null



node ptr=head;


ptr=ptr.next;


head=ptr;




Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here