Q2: In a demo class, write a java static method called addAfterNNodes that receives a reference parameter named list of

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Q2: In a demo class, write a java static method called addAfterNNodes that receives a reference parameter named list of

Post by answerhappygod »

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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply