Question

g- Method remove(int n): it removes the node number n, and returns the element in that node,assuming the first node number is 1. You need to check that n is

within the range of nodes in the list, otherwise method get returns null. To make your code more efficient, you should start from the end (header or trailer) that is closer to the target node.What is the complexity of your method?Test the method in main.

Fig: 1