Question: Q 2 ( 2 0 points ) : Linked - Lists Consider the following four ( 4 ) linked - list methods ( Assume they
Q points: LinkedLists
Consider the following four linkedlist methods Assume they are implemented and ready to be used as specified below:
insert at position takes a position int value and a node, and it inserts the new node at that position in the list including the first and last positions. peek at position takes a position int value and it returns the data stored in the node at that position in the list including the first and last positions. delete from position takes a position int value and it deletes a node located at that position in the list including the first and last positions. listsize returns the current size of the linkedlist.
Using ONLY the above methods, write detailed Englishlike pseudocode or JavaLike code for a new linkedlist method, call it move node to move a node from one position to another in the same linkedlist. The specification of this new method is:
METHOD movenode int P int P;
where is the removal position and is the insertion position.
Yous pseudocode code must be detailed, logically correct, and complete. Check for all special cases including the validation of the position values.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
