Assuming that a method named addToStart places a node at the

Assuming that a method named addToStart places a node at the beginning of a linked list, and a method named outputList prints out the contents of a linked list beginning with the node at the front, what output is produced by the following code?

LinkedList1 list = new LinkedList1( );

list.addToStart(“apple”, 1);

list.addToStart(“hot dogs”, 12);

list.addToStart(“mustard”, 1);

list.outputList( );

Solution

Answer :

Assuming that a method named addToStart places a node at the beginning of a linked list, and a method named outputList prints out the contents of a linked list beginning with the node at the front, what output is produced by the following code?

LinkedList1 list = new LinkedList1( );

list.addToStart(“apple”, 1);

list.addToStart(“hot dogs”, 12);

list.addToStart(“mustard”, 1);

list.outputList( );

Answer :

mustard 1

hot dogs 12

apple 1

Explanation :

Linkked list conatians 3 nodes,the output is

mustard 1

hot dogs 12

apple 1

Assuming that a method named addToStart places a node at the beginning of a linked list, and a method named outputList prints out the contents of a linked list

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site