Q2: In a demo class, write a java static method
called addAfterNNodes that
receives a reference parameter
named list of type LLNode of
integer values, int N and int value. Your method should add a new
node with an info value after
first N nodes form the
LLNode.
Hint [The value of N should
not be greater than the number of nodes in the LLNode list]
For example, if the list contains:
1
3
5
4
list
Then after calling the
method addAfterNNodes with
N=4, and value =30 the list
becomes as follows:
1
30
3
5
4
list
Example2, if the list contains:
1
3
5
4
list
Then after calling the
method addAfterNNodes with
N=3, and value =10 the list
becomes as follows:
4
5
3
10
1
Q2: In a demo class, write a java static method
called addAfterNNodes that
receives a reference parameter
named list of type LLNode of
integer values, int N and int value. Your method should add a new
node with an info value after
first N nodes form the
LLNode.
Hint [The value of N should
not be greater than the number of nodes in the LLNode list]
For example, if the list contains:
1
3
5
4
list
Then after calling the
method addAfterNNodes with
N=4, and value =30 the list
becomes as follows:
1
30
3
5
4
list
Example2, if the list contains:
1
3
5
4
list
Then after calling the
method addAfterNNodes with
N=3, and value =10 the list
becomes as follows:
4
5
3
10
1
Q2: In a demo class, write a java static method called addAfterNNodes that receives a reference parameter named list of
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am