Question: pleas using java pseudocode Write a method (pseudocode) to swap ith and jth node (not elements) of a Single Linked List and return the head

pleas using java pseudocode

Write a method (pseudocode) to swap ith and jth node (not elements) of a Single Linked List and return the head node of the new/updated linked list. Assume that i and j are valid and in the range of node count of the linked list. What is the space and time complexity of your solution?

Input: 12345

i=2,j= 4

Output: 14325

Input: 5371

i = 1, j = 4

Output: 1375

Input: 4

i=1, j= 1

output: 4

/* precondition: i> 0,j>0 and i<=linked list size, j<=linked list size,1<=j */9

Node swap(Node head, int i , int j ):

// your code goes here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!