LinkedList Java | Sololearn: Learn to code for FREE!

+3

LinkedList Java

Hi, I got the exercise to write java code using Linked Lists. It says: "You can use the following node definition for this example: type Node = { int value Node next } The following recursive algorithm printReversed ( β†“ Node n) returns a list (where n is the Starting node is) upside down (for the above list would be the sequence of numbers 5 4 3 2 1 are output). printReversed (↓ Node n) { if (n! = null) { print reversed (↓ n.next) write (↓ n.value) } } " This is just part of it, that is unclear to me. Now, I need to convert this "pseudo code" to java code, and to modify printReversed(). That wouldn't be problem if I would know how to convert this type Node thingy to java, I know it should be done with new class Node and its constructor but it gives me error when calling method "String cannot be converted to Node". I'm short on time so please help. 😁😁

5/26/2018 11:37:02 AM

Amar

2 Answers

New Answer

+3

Nevermind, I managed to do it with 2 constructors. Thanks for offering for help.

+2

Could you show the code?