Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 486 Bytes

File metadata and controls

29 lines (22 loc) · 486 Bytes

importance: 5


Output a single-linked list

Let's say we have a single-linked list (as described in the chapter info:recursion):

letlist={value: 1,next: {value: 2,next: {value: 3,next: {value: 4,next: null}}}};

Write a function printList(list) that outputs list items one-by-one.

Make two variants of the solution: using a loop and using recursion.

What's better: with recursion or without it?

close