Question: java 2) (15 pts) Write a function that returns the data of the kihelement of a doubly linked list. If the number is neatiua start
2) (15 pts) Write a function that returns the data of the kihelement of a doubly linked list. If the number is neatiua start looking from the end, if it is positive, then start looking from the head. NOTE: The function takes ontvan integer and a pointer to the head. There is no pointer to tail class Doubly int item; Doubly next; Doubly prev: For example given the following data: Node 3 Node 4 Node 5 Node 1 (head) 10 Node 2 20 30 40 50 Example The 4th item is 40. The -4th item is 20 Precondition: The list will not be empty. The argument K will not be outside the list. K will not be 0. There is no tail. I/Function header int getItem(int k, Doubly head) { mode to deal with k when it in a positive number //Code to deal with k if it is negative number I/Have to go all the way to the end and then start counting backwards else
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
