Question: Suppose that the Node class representing the nodes of a linked list has been declared. public class Node { public int data; public Node link;

Suppose that the Node class representing the nodes of a linked list has been declared.

public class Node {

public int data;

public Node link;

}

Also suppose that you have implemented a class called "LinkedList" which keeps only the first node of the linked list.

public class LinkedList {

private Node first;

}

Write a method called public void printEvenSeq() that prints all the subsequences that start and end with an even number. Only the even numbers within the sequences will be printed.

Example:

Linked List

17 22 42 13 46 18 19

Output

22

22 42

22 42 46

22 42 46 18

42

42 46

42 46 18

46

46 18

18

You can use another data structure to keep addtional information. But you are not allowed to keep the original elements in another data structure. The original elements should remain and be processed in the linked list.

Your reply should be in text form (not image or screen shot).

java data structures and algorithm?

 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!